/*
  Bitcoin Canon — Drawers & Sheets
  Source drawer (provenance), mobile search sheet, mobile picker sheet.
  These are the apparatus — they should feel like witness records, not utility panels.

  All three sheet surfaces use var(--c-panel), never a fixed hex. They were
  hard-coded to #101009, which is correct only in the dark themes: in Vellum the
  page supplies dark ink, so the sheet put dark text on a dark surface — the
  title and input measured 1.20:1, the close control 2.31:1. The fields inside
  sit on --c-panel-2 so they still read as inset on the panel.
*/

/* — Source drawer ————————————————————————————— */
.source-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.source-drawer:not([hidden]) { pointer-events: auto; }

.source-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
  cursor: pointer;
}

.source-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(500px, 94vw);
  overflow-y: auto;
  background: var(--c-panel);
  border-left: 1px solid var(--c-line-strong);
  box-shadow: var(--elevation-2);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.source-drawer-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 4;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-none);
  background: var(--c-panel);
  color: var(--c-muted);
  padding: .35rem .55rem;
  font-family: var(--f-mono);
  font-size: var(--type-2xs);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.source-drawer-close:hover {
  color: var(--c-ink);
  border-color: var(--c-line-strong);
}

/* The dialog already has an accessible title; the visible hierarchy lives in
   the record header so the reference is not repeated before source data. */
.source-drawer-panel > .eyebrow,
.source-drawer-panel > h3 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* — Witness Record — provenance is the hero ——————————— */
.witness-record { background: var(--c-panel); }

.record-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-4);
  padding: 1.55rem 5.2rem 1.3rem 1.55rem;
  border-bottom: 1px solid var(--c-line);
}

.record-seal {
  display: grid;
  place-items: center;
  width: 2.65rem;
  height: 2.65rem;
  margin-top: .15rem;
  border: 1px solid var(--c-verify);
  border-radius: 50%;
  background: var(--c-seal-ground);
  color: var(--c-verify);
  font: 700 1rem/1 var(--f-mono);
}

.record-seal.is-review {
  border-color: var(--c-seal);
  color: var(--c-seal-2);
}

.record-kicker {
  margin-bottom: .3rem;
  color: var(--c-dim);
  font: 600 var(--type-2xs)/1.4 var(--f-mono);
  letter-spacing: .2em;
  text-transform: uppercase;
}

.record-ref {
  display: block;
  color: var(--c-ink);
  font: 500 1.9rem/1.05 var(--f-serif);
}

.record-context {
  display: block;
  margin-top: .3rem;
  color: var(--c-muted);
  font: italic .92rem/1.4 var(--f-serif);
}

.record-status {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  margin-top: .7rem;
  color: var(--c-ink);
  font: 600 var(--type-xs)/1.4 var(--f-mono);
}

.record-status i,
.record-integrity i {
  display: inline-block;
  width: .45rem;
  height: .45rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--c-verify);
  box-shadow: 0 0 0 1px var(--c-seal-ground);
}

.record-status.is-review i,
.record-integrity.is-review i {
  background: var(--c-seal);
}

.record-citation {
  margin: 0;
  padding: 1.25rem 1.55rem 1.35rem;
  border-bottom: 1px solid var(--c-line);
  background: transparent;
}

.record-citation > span {
  display: block;
  margin-bottom: .4rem;
  color: var(--c-dim);
  font: 600 var(--type-2xs)/1.4 var(--f-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.record-citation > strong {
  display: block;
  color: var(--c-ink);
  font: 600 var(--type-sm)/1.5 var(--f-mono);
}

.record-citation > p {
  margin-top: 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--c-line-strong);
  color: var(--c-ink);
  font: 400 1.08rem/1.7 var(--f-serif);
}

.record-provenance {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 1rem 1.55rem 1.15rem;
  border-bottom: 1px solid var(--c-line);
  font: 400 var(--type-xs)/1.65 var(--f-mono);
}

.record-provenance > div {
  display: grid;
  grid-template-columns: 7.4rem minmax(0, 1fr);
  gap: var(--space-4);
  padding: .3rem 0;
  border: 0;
  border-radius: var(--radius-none);
  background: transparent;
}

.record-provenance dt {
  padding-top: .08rem;
  color: var(--c-dim);
  font-size: var(--type-2xs);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.record-provenance dd {
  min-width: 0;
  margin: 0;
  color: var(--c-muted);
  font: inherit;
  overflow-wrap: anywhere;
}

.record-provenance > div:first-child dd { color: var(--c-ink); }
.record-provenance a {
  color: var(--c-muted);
  text-decoration: underline;
  text-decoration-color: var(--c-line-strong);
  text-underline-offset: 3px;
}

.record-integrity {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  color: var(--c-ink) !important;
}

.record-apparatus,
.record-study {
  padding: 1rem 1.55rem 1.1rem;
  border-bottom: 1px solid var(--c-line);
}

.record-apparatus {
  border-left: 2px solid var(--c-seal);
  background: color-mix(in srgb, var(--c-apparatus-ground) 46%, transparent);
}

.record-apparatus > p,
.record-study p {
  margin-bottom: .45rem;
  color: var(--c-dim);
  font: 600 var(--type-2xs)/1.4 var(--f-mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.record-apparatus > strong,
.record-apparatus > span {
  display: block;
  color: var(--c-muted);
  font: 400 var(--type-xs)/1.65 var(--f-mono);
}

.record-apparatus > strong {
  margin-bottom: .3rem;
  color: var(--c-ink);
  letter-spacing: .04em;
}

/* Source drawer actions */
.source-drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin: 0;
  padding: .9rem 1.55rem 1.1rem;
  border-top: 0;
}

.source-drawer-actions a,
.source-drawer-actions button {
  border: 0;
  border-bottom: 1px solid var(--c-line);
  border-radius: var(--radius-none);
  background: transparent;
  color: var(--c-muted);
  padding: .15rem 0;
  font-size: var(--type-xs);
  font-family: var(--f-mono);
  letter-spacing: .04em;
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.source-drawer-actions a:hover,
.source-drawer-actions button:hover {
  color: var(--c-ink);
  border-color: var(--c-line-strong);
}

/* Integrity seal colors */
.integrity-verified { border-color: var(--c-verify); color: var(--c-ink); }
.integrity-needs-review { border-color: var(--c-line-strong); color: var(--c-muted); }
.integrity-partial { border-color: var(--c-line); color: var(--c-muted); }

/* — Mobile search sheet ————————————————————————— */
.mobile-search-sheet {
  position: fixed;
  inset: 0;
  z-index: 110;
  pointer-events: none;
}
.mobile-search-sheet:not([hidden]) { pointer-events: auto; }

.mobile-search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(2px);
  cursor: pointer;
}

.mobile-search-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--c-panel);
  border-top: 1px solid var(--c-line-amber);
  border-radius: 1.2rem 1.2rem 0 0;
  padding: 1.25rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .45);
}

.mobile-search-close {
  position: absolute;
  top: .85rem;
  right: 1rem;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: transparent;
  color: var(--c-muted);
  padding: .3rem .7rem;
  font-size: .72rem;
}

.mobile-search-panel .eyebrow { display: none; }

#mobileSearchTitle {
  font-family: var(--f-serif);
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: .85rem;
  color: var(--c-ink);
}

#mobileSearchInput {
  display: block;
  width: 100%;
  border: 1px solid var(--c-line-strong);
  border-radius: .75rem;
  background: var(--c-panel-2);
  color: var(--c-ink);
  padding: .85rem 1rem;
  font-size: 1rem;
  font-family: var(--f-sans);
  outline: none;
  transition: border-color var(--fast) var(--ease);
}

#mobileSearchInput:focus {
  border-color: var(--c-seal);
}

/* The id-level `outline: none` above would otherwise beat the global
   :focus-visible ring, leaving keyboard users with only a border tint. */
#mobileSearchInput:focus-visible {
  outline: 2px solid var(--c-seal);
  outline-offset: 2px;
}

/* The panels take focus when they open; they are containers, not controls,
   so the ring would only add noise. Focus moves on to a real control. */
.source-drawer-panel:focus,
.mobile-search-panel:focus,
.mobile-picker-panel:focus {
  outline: none;
}

#mobileSearchInput::placeholder {
  color: var(--c-dim);
}

.mobile-search-quick {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .75rem;
}

.mobile-search-quick button {
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: transparent;
  color: var(--c-muted);
  padding: .35rem .7rem;
  font-size: .78rem;
}

.mobile-search-quick button:hover {
  border-color: var(--c-line-strong);
  color: var(--c-ink);
}

/* — Mobile picker sheet ————————————————————————— */
.mobile-picker-sheet {
  position: fixed;
  inset: 0;
  z-index: 110;
  pointer-events: none;
}
.mobile-picker-sheet:not([hidden]) { pointer-events: auto; }

.mobile-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(2px);
  cursor: pointer;
}

.mobile-picker-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 72vh;
  overflow-y: auto;
  background: var(--c-panel);
  border-top: 1px solid var(--c-line-amber);
  border-radius: 1.2rem 1.2rem 0 0;
  padding: 1.25rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px rgba(0, 0, 0, .45);
}

.mobile-picker-close {
  position: absolute;
  top: .85rem;
  right: 1rem;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: transparent;
  color: var(--c-muted);
  padding: .3rem .7rem;
  font-size: .72rem;
}

#mobilePickerKicker { font-size: .62rem; letter-spacing: .12em; }

#mobilePickerTitle {
  font-family: var(--f-serif);
  font-size: 1.4rem;
  font-weight: 500;
  margin-bottom: .85rem;
  color: var(--c-ink);
}

.mobile-picker-list {
  display: grid;
  gap: .3rem;
}

.mobile-picker-list button {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  width: 100%;
  padding: .6rem 0;
  border: 0;
  border-bottom: 1px solid var(--c-line);
  border-radius: 0;
  background: transparent;
  color: var(--c-muted);
  text-align: left;
  font-family: var(--f-serif);
  font-size: 1.05rem;
  transition: color var(--fast) var(--ease);
}

.mobile-picker-list button:last-child { border-bottom: 0; }

.mobile-picker-list button:hover,
.mobile-picker-list button.active {
  color: var(--c-ink);
}

.mobile-picker-list button small {
  color: var(--c-amber);
  font-family: var(--f-mono);
  font-size: .62rem;
  font-weight: 600;
  margin-right: .1rem;
}

/* — Mobile appbar background ———————————————————— */
.mobile-appbar-bg {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: env(safe-area-inset-top, 0);
  background: var(--c-bg);
  z-index: 50;
}

/* Verse action strip (in drawer) */
.verse-action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.verse-action-strip button {
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: transparent;
  color: var(--c-muted);
  padding: .35rem .7rem;
  font-size: .75rem;
  font-family: var(--f-sans);
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.verse-action-strip button:hover {
  color: var(--c-ink);
  border-color: var(--c-line-strong);
}
