/* ==========================================================================
   JACK GHAZI — CARD  ·  "THE SWITCHBOARD, catalogued"
   Design system: The Meridian. Dark console, one live line, museum labels.
   All paths relative (page is served at / and at /card/).
   ========================================================================== */

/* ---------- 1. FONTS (self-hosted, relative to this stylesheet) ---------- */

@font-face {
  font-family: 'Fraunces';
  src: url('../fonts/Fraunces.woff2') format('woff2');
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('../fonts/Fraunces-italic.woff2') format('woff2');
  font-weight: 300 600;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('../fonts/Newsreader.woff2') format('woff2');
  font-weight: 300 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('../fonts/Newsreader-italic.woff2') format('woff2');
  font-weight: 300 600;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Martian Mono';
  src: url('../fonts/MartianMono.woff2') format('woff2');
  font-weight: 300 600;
  font-stretch: 75% 112.5%;
  font-style: normal;
  font-display: swap;
}

/* ---------- 2. TOKENS ---------- */

:root {
  --nightwatch: #1B2029;
  --tablet:     #252C37;
  --bone:       #E8E1CF;
  --ash:        #8B93A0;
  --verdigris:  #79AD9C;
  --bronze:     #C9A66B;

  --verdigris-rgb: 121, 173, 156;
  --bronze-rgb:    201, 166, 107;
  --bone-rgb:      232, 225, 207;
  --night-rgb:     27, 32, 41;

  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --body:    'Newsreader', Georgia, 'Times New Roman', serif;
  --mono:    'Martian Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;

  --pad: 24px;
  --rail-h: 52px;

  color-scheme: dark;
}

/* ---------- 3. RESET / PAGE ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--nightwatch);
  color: var(--bone);
  font-family: var(--body);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* very subtle grain — inline feTurbulence, no external request */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

h1, p, dl, dd, dt, figure { margin: 0; }
dd { margin-inline-start: 0; }

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--verdigris);
  outline-offset: -3px;
}

.panel { position: relative; z-index: 1; }

/* ---------- 4. STATUS RAIL ---------- */

.rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--rail-h);
  padding: 0 var(--pad);
  background: var(--tablet);
  border-bottom: 1px solid rgba(var(--verdigris-rgb), 0.35);
}

.rail__side {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.65rem;
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
}
.rail__side--end { justify-content: flex-end; min-width: 0; }
.rail__clock { color: var(--ash); font-variant-numeric: tabular-nums; }

/* lamps */
.lamp {
  position: relative;
  flex: none;
  width: 6px;
  height: 6px;
}
.lamp::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--verdigris);
  animation: breathe 4s ease-in-out infinite;
}
.lamp--gold::before { background: var(--bronze); }

/* first ring — one concentric pulse, 500ms after load */
.lamp--ring::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  border: 1px solid var(--verdigris);
  opacity: 0;
  animation: ring 1.2s ease-out 0.5s 1 forwards;
}

@keyframes breathe {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}
@keyframes ring {
  0%   { transform: scale(1);   opacity: 0.85; }
  100% { transform: scale(5.5); opacity: 0; }
}

/* ---------- 5. NAMEPLATE ---------- */

.plate { padding: 26px var(--pad); background: var(--nightwatch); }

.nameplate__name {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(2.5rem, 11vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bone);
  margin: 0 0 14px;
}

.nameplate__role {
  font-family: var(--body);
  font-weight: 300;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ash);
  max-width: 34ch;
}
.nameplate__role .hl { color: var(--bone); }
.nameplate__role em { font-style: italic; }

/* museum label block */
.label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 16px;
  row-gap: 9px;
  align-items: baseline;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid rgba(var(--bone-rgb), 0.08);
}
.label dt {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
}
.label dd {
  font-family: var(--body);
  font-weight: 300;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--bone);
}
.label__live { color: var(--verdigris); }
.label__live em { font-style: italic; }

/* ---------- 6. THE LINE (hero plate) ---------- */

.line {
  margin: 4px var(--pad) 0;
  padding: 22px 18px 18px;
  text-align: center;
  background: var(--nightwatch);
  border: 1px solid var(--tablet);
  border-top: 1px solid rgba(var(--verdigris-rgb), 0.55);
  border-radius: 2px;
  box-shadow: inset 0 2px 14px rgba(0, 0, 0, 0.45);
}

.line__num {
  display: block;
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(1.9rem, 8.5vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.line__num:active { color: var(--verdigris); }

.line__wire {
  display: block;
  height: 1px;
  margin: 16px 0 12px;
  background-image: linear-gradient(90deg,
    rgba(var(--verdigris-rgb), 0.14) 0%,
    rgba(var(--verdigris-rgb), 0.14) 38%,
    rgba(var(--verdigris-rgb), 0.95) 50%,
    rgba(var(--verdigris-rgb), 0.14) 62%,
    rgba(var(--verdigris-rgb), 0.14) 100%);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: wire 4s linear infinite;
}
@keyframes wire {
  from { background-position: 150% 0; }
  to   { background-position: -50% 0; }
}

.line__note {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.62rem;
  line-height: 1.5;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--verdigris);
}
/* the caption breaks as two deliberate lines, never an orphan */
.line__note-a,
.line__note-b { display: inline-block; white-space: nowrap; }

/* ---------- 7. THE RACK ---------- */

.rack {
  margin-top: 26px;
  border-top: 1px solid var(--nightwatch);
}

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 62px;
  margin: 0;
  padding: 12px var(--pad);
  background: var(--tablet);
  border: 0;
  border-bottom: 1px solid var(--nightwatch);
  border-radius: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  transition: background-color 0.18s ease;
}

.row__key {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.row .lamp { width: 8px; height: 8px; }
.row .lamp::before { animation: none; opacity: 1; }

.row__label {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.72rem;
  line-height: 1.2;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
}

.row__val {
  min-width: 0;
  font-family: var(--body);
  font-weight: 300;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--ash);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row__val--nowrap { white-space: nowrap; }
.row__val--mono {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.row:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}
.row:active .row__label { color: var(--bone); }

/* 03 — the hero key */
.row--hero {
  background:
    linear-gradient(rgba(var(--bronze-rgb), 0.04), rgba(var(--bronze-rgb), 0.04)),
    var(--tablet);
  border-left: 2px solid var(--bronze);
}
.row--hero .row__label { color: var(--bone); }
.row--hero .row__val { color: var(--bronze); }

/* ---------- 8. SHARE DRAWER ---------- */

.drawer {
  display: grid;
  grid-template-rows: 0fr;
  background: var(--nightwatch);
  transition: grid-template-rows 0.42s cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer[data-open="true"] { grid-template-rows: 1fr; }
.drawer__clip { overflow: hidden; min-height: 0; }

/* keep collapsed content out of the tab order without blocking the reveal */
.drawer[data-open="false"] .drawer__in {
  visibility: hidden;
  transition: visibility 0s linear 0.42s;
}
.drawer[data-open="true"] .drawer__in {
  visibility: visible;
  transition: visibility 0s linear 0s;
}

.drawer__in {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 26px var(--pad) 28px;
}

.drawer__cap {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.65rem;
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ash);
  text-align: center;
}

/* QR plate + registration ticks */
.qr {
  position: relative;
  width: 184px;   /* 160px QR + 12px plate padding on each side */
  height: 184px;
  max-width: 100%;
  /* dark modules on bone stock: every scanner reads it, and the card
     gets its one pop of light — inverted codes fail on older readers */
  padding: 12px;
  background: var(--bone);
  border: 1px solid rgba(var(--bone-rgb), 0.07);
}
.qr__svg { display: block; width: 100%; height: 100%; }
.qr__svg path { stroke: var(--nightwatch); }

.tick {
  position: absolute;
  width: 6px;
  height: 6px;
}
.tick--tl { top: -1px; left: -1px;  border-top: 1px solid var(--bronze); border-left: 1px solid var(--bronze); }
.tick--tr { top: -1px; right: -1px; border-top: 1px solid var(--bronze); border-right: 1px solid var(--bronze); }
.tick--bl { bottom: -1px; left: -1px;  border-bottom: 1px solid var(--bronze); border-left: 1px solid var(--bronze); }
.tick--br { bottom: -1px; right: -1px; border-bottom: 1px solid var(--bronze); border-right: 1px solid var(--bronze); }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--verdigris);
  border: 1px solid rgba(var(--verdigris-rgb), 0.55);
  border-radius: 999px;
  transition: background-color 0.18s ease, color 0.18s ease;
}
.pill:active,
.pill:hover {
  background: rgba(var(--verdigris-rgb), 0.12);
  color: var(--bone);
}

/* ---------- 9. PATCH BAY ---------- */

.patch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--nightwatch);
  border-top: 1px solid var(--nightwatch);
}
.patch__tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  min-height: 76px;
  padding: 18px var(--pad);
  background: var(--tablet);
  transition: background-color 0.18s ease;
}
.patch__key {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.65rem;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ash);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.18s ease;
}
.patch__val {
  font-family: var(--body);
  font-weight: 300;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.2;
  color: var(--bronze);
}
.patch__tile:hover .patch__key,
.patch__tile:active .patch__key { color: var(--verdigris); }
.patch__tile:active { transform: translateY(1px); }

/* ---------- 10. FOOTER ---------- */

.foot {
  padding: 22px var(--pad) 30px;
  padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  background: var(--nightwatch);
}
.foot p {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.6rem;
  line-height: 1.6;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ash);
}

/* ---------- 11. NARROW PHONES (320–360) ---------- */

@media (max-width: 359px) {
  :root { --pad: 18px; }
  .row__label { font-size: 0.68rem; letter-spacing: 0.14em; }
  .row__val { font-size: 0.9rem; }
  .nameplate__role { font-size: 1rem; }
}

/* ---------- 12. DESKTOP — the console as an object on the table ---------- */

@media (min-width: 900px) {
  :root { --pad: 40px; }

  body { padding: 64px 32px 72px; }

  .panel {
    max-width: 880px;
    margin: 0 auto;
    background: var(--tablet);
    border: 1px solid rgba(var(--bronze-rgb), 0.35);
    border-radius: 2px;
    box-shadow:
      0 40px 90px -30px rgba(0, 0, 0, 0.75),
      0 8px 24px rgba(0, 0, 0, 0.35);
    overflow: hidden;
  }

  /* the rail reads as a recessed strip across the panel head */
  .rail {
    padding: 0 var(--pad);
    background:
      linear-gradient(rgba(var(--night-rgb), 0.45), rgba(var(--night-rgb), 0.45)),
      var(--tablet);
    box-shadow: inset 0 -14px 20px -18px rgba(0, 0, 0, 0.9);
  }

  .console {
    display: grid;
    grid-template-columns: 55% 45%;
    align-items: stretch;
  }
  .col { min-width: 0; }
  .col--a {
    display: flex;
    flex-direction: column;
    padding: 40px 0 40px;
    border-right: 1px solid rgba(var(--night-rgb), 0.9);
  }
  .col--b { padding: 0 0 4px; }

  /* left column sits on the panel surface */
  .plate,
  .drawer,
  .patch,
  .foot { background: transparent; }

  .nameplate { padding: 0 var(--pad) 0; }
  .nameplate__name { font-size: 4rem; margin-bottom: 18px; }
  .nameplate__role { font-size: 1.1rem; max-width: 30ch; }
  .label { margin-top: 26px; padding-top: 22px; }

  .line {
    /* sinks to the column foot so the plate bottom-aligns with the patch bay */
    margin: auto var(--pad) 0;
    padding: 26px 20px 20px;
    background: var(--nightwatch);
  }
  .label { margin-bottom: 34px; }

  /* right column: rack, then the drawer permanently open, then patch bay */
  .rack { margin-top: 0; border-top: 0; }
  .row {
    padding-left: 32px;
    padding-right: 32px;
    background:
      linear-gradient(rgba(var(--bone-rgb), 0.03), rgba(var(--bone-rgb), 0.03)),
      var(--tablet);
    border-bottom: 1px solid rgba(var(--night-rgb), 0.9);
  }
  .row:hover { background: var(--nightwatch); }
  .row:hover .row__label { color: var(--bone); }
  .row--hero {
    background:
      linear-gradient(rgba(var(--bronze-rgb), 0.06), rgba(var(--bronze-rgb), 0.06)),
      var(--tablet);
  }
  .row--hero:hover {
    background:
      linear-gradient(rgba(var(--bronze-rgb), 0.1), rgba(var(--bronze-rgb), 0.1)),
      var(--nightwatch);
  }

  /* row 04 is not needed — the drawer never closes on desktop */
  .row--share { display: none; }
  .drawer { grid-template-rows: 1fr; }
  .drawer[data-open="false"] .drawer__in { visibility: visible; }
  .drawer__in { padding: 30px 32px 26px; }

  .patch { border-top: 1px solid rgba(var(--night-rgb), 0.9); }
  .patch__tile {
    padding: 18px 22px;
    background:
      linear-gradient(rgba(var(--bone-rgb), 0.03), rgba(var(--bone-rgb), 0.03)),
      var(--tablet);
  }
  .patch__tile:hover { background: var(--nightwatch); }

  .foot {
    padding: 20px var(--pad) 22px;
    border-top: 1px solid rgba(var(--night-rgb), 0.9);
  }
}

/* mid range: keep the panel feel, single column */
@media (min-width: 600px) and (max-width: 899px) {
  body { padding: 40px 24px; }
  .panel {
    max-width: 520px;
    margin: 0 auto;
    border: 1px solid rgba(var(--bronze-rgb), 0.3);
    border-radius: 2px;
    box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.7);
    overflow: hidden;
  }
}

/* ---------- 13. REDUCED MOTION ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .lamp::before { opacity: 1; }
  .lamp--ring::after { display: none; }
  .line__wire {
    background-image: none;
    background-color: rgba(var(--verdigris-rgb), 0.55);
  }
  .drawer { transition: none; }
}
