/* LineDrifter — The Face aesthetic: cover-story minimalism, oversized type.
   ────────────────────────────────────────────────────── */

:root {
  --bg: #ebe7df;
  --ink: #0c0c0c;
  --accent: #ff3b1f;
  --font-body: 'Inter', 'Helvetica Neue', sans-serif;
  --font-ui: 'Inter', 'Helvetica Neue', sans-serif;
  --grain-opacity: 0.03;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Grain overlay (subtle paper texture) ───────────────── */
.grain-overlay {
  position: fixed;
  inset: -2%;
  pointer-events: none;
  z-index: 50;
  opacity: var(--grain-opacity);
  mix-blend-mode: multiply;
  background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="2.4" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)"/></svg>');
}

/* ── Shared card chrome ─────────────────────────────────── */
.ld-card {
  position: relative;
  appearance: none;
  border: 1px solid var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.35s cubic-bezier(.2,.7,.2,1),
    color 0.35s cubic-bezier(.2,.7,.2,1),
    transform 0.25s cubic-bezier(.2,.7,.2,1),
    box-shadow 0.25s cubic-bezier(.2,.7,.2,1);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.ld-card.is-locked { opacity: 0.78; }

/* Drift animation: word fades out / flips / fades back in while the card
   itself does a subtle scale pulse. Both run for the same 0.4s window. */
.ld-card.is-updating .fc-word {
  animation: ldFlipBalanced 0.4s cubic-bezier(.2,.7,.2,1);
}
.ld-card.is-updating {
  animation: ldCardPulse 0.4s cubic-bezier(.2,.7,.2,1);
}
@keyframes ldFlipBalanced {
  0%   { opacity: 1; transform: translateY(0); filter: blur(0); }
  40%  { opacity: 0; transform: translateY(-14px); filter: blur(3px); }
  60%  { opacity: 0; transform: translateY(14px); filter: blur(3px); }
  100% { opacity: 1; transform: translateY(0); filter: blur(0); }
}
@keyframes ldCardPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.985); }
}
.ld-lock {
  font-size: 11px;
  opacity: 0.45;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 2px;
  user-select: none;
  transition: opacity 0.2s;
}
.ld-lock:hover { opacity: 1; }
.ld-card.is-locked .ld-lock { opacity: 0.85; }

/* ── Action bar (universal) ─────────────────────────────── */
.ld-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-family: var(--font-ui, monospace);
  font-size: 11px;
  letter-spacing: 0.08em;
  z-index: 10;
}
.ld-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-ui, monospace);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 0;
  transition: background 0.2s, color 0.2s;
}
.ld-action:hover { background: var(--ink); color: var(--bg); }
.ld-action-primary { background: var(--ink); color: var(--bg); }
.ld-action-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.ld-action-icon { font-size: 13px; }
.ld-action-hint {
  margin-left: auto;
  opacity: 0.5;
  font-size: 10px;
  text-transform: uppercase;
}
@media (max-width: 720px) {
  .ld-action span:last-child:not(.ld-action-icon) { display: none; }
  .ld-action-hint { display: none; }
}

/* ─────────────────────────────────────────────────────────
   The Face stage layout
   ───────────────────────────────────────────────────────── */
.stage-face {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  padding: 22px 28px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 14px;
}
.fc-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 10px;
}
.fc-logo {
  font-family: 'Antonio', 'Oswald', sans-serif;
  font-weight: 700;
  font-size: clamp(1.3rem, 2.2vw, 1.8rem);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.fc-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
}
.fc-canvas {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: clamp(20px, 3vw, 48px);
  align-items: center;
}
.fc-cover-line {
  font-family: 'Antonio', 'Oswald', sans-serif;
  font-weight: 700;
  font-size: clamp(2.4rem, 8vw, 6rem);
  line-height: 0.88;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}
.fc-cover-line em {
  font-style: italic;
  font-family: 'Antonio', 'Oswald', sans-serif;
  color: var(--accent);
}
.fc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  height: 100%;
  min-height: 60vh;
}
.fc-card {
  padding: 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  gap: 8px;
  background: transparent;
  color: var(--ink);
}
.fc-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.fc-cat { font-weight: 600; }
.fc-word {
  font-family: 'Antonio', 'Oswald', sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 0.92;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  align-self: center;
  /* Syllable-aware wrapping: each .syll is an inline unit; the word
     breaks BETWEEN syllables only — never inside one. */
  word-break: keep-all;
  overflow-wrap: normal;
  hyphens: none;
  max-width: 100%;
}
.syll {
  display: inline-block;
  white-space: nowrap; /* never break inside a syllable */
}

.fc-card-foot {
  font-size: 10px;
  letter-spacing: 0.16em;
  opacity: 0.65;
  text-transform: uppercase;
}
@media (max-width: 760px) {
  .fc-canvas { grid-template-columns: 1fr; }
  .fc-cover-line { font-size: clamp(2rem, 9vw, 3.4rem); }
}

/* The Face — alphabet rail (songwriting helper) */
.fc-alphabet {
  display: grid;
  gap: 6px;
  padding: 10px 0 4px;
  border-top: 1.5px solid var(--ink);
  margin-top: 6px;
}
.fc-alphabet-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.fc-tab {
  padding: 4px 9px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  opacity: 0.55;
  border-radius: 0;
  font: inherit;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: opacity 0.15s, background 0.15s;
}
.fc-tab.is-on {
  opacity: 1;
  background: var(--ink);
  color: var(--bg);
}
.fc-tab:hover { opacity: 1; }

.fc-alphabet-row {
  display: grid;
  grid-template-columns: repeat(26, 1fr);
  gap: 1px;
  align-items: stretch;
}
.fc-letter {
  font-family: 'Antonio', 'Oswald', sans-serif;
  font-weight: 500;
  font-size: clamp(11px, 1.4vw, 14px);
  letter-spacing: 0;
  background: transparent;
  border: none;
  color: var(--ink);
  opacity: 0.32;
  padding: 6px 0;
  border-radius: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  cursor: pointer;
}
.fc-letter:hover { opacity: 1; }
.fc-letter.is-on {
  opacity: 1;
  color: var(--accent);
  font-weight: 700;
}
.fc-letter-clear {
  grid-column: span 1;
  opacity: 0.5;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
}
.fc-letter-clear:hover { opacity: 1; }

.fc-card.is-active { box-shadow: inset 0 0 0 1px var(--ink); }
@media (max-width: 600px) {
  .fc-alphabet-row { grid-template-columns: repeat(13, 1fr); }
}


/* Syllable-aware wrapping for poster word containers. */
.pp-word, .pp-stack-word, .pp-runon-word {
  word-break: keep-all;
  overflow-wrap: normal;
  hyphens: none;
}


/* Poster preview ───────────────────────────────────────── */
.ld-poster-preview {
  margin: 18px 0;
  background: #fafaf5;
  border: 1px solid var(--ink);
  aspect-ratio: 3 / 4;
  max-height: 400px;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  font-family: 'Familjen Grotesk', sans-serif;
}
.ld-poster-inner {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 24px;
  color: #1a1a1a;
  background: #fafaf5;
}
.pp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
}
.pp-cell {
  border: 1px solid #1a1a1a;
  padding: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 6px;
}
.pp-cat { font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 0.18em; opacity: 0.7; text-transform: uppercase; }
.pp-word {
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  font-size: clamp(20px, 4vw, 36px);
  line-height: 1; align-self: end;
}
.pp-stack { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.pp-stack-row {
  display: flex; align-items: baseline; gap: 12px;
  border-bottom: 1px solid #1a1a1a;
  padding-bottom: 6px;
}
.pp-stack-cat {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  opacity: 0.7;
  min-width: 70px;
  text-transform: uppercase;
}
.pp-stack-word {
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  font-size: clamp(22px, 5vw, 44px);
  line-height: 1.1;
  margin-left: auto;
}
.pp-runon {
  display: flex; flex-wrap: wrap; gap: 12px 18px;
  align-content: center; justify-content: center;
  align-items: baseline;
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  font-size: clamp(24px, 4.5vw, 48px);
  line-height: 1;
  text-align: center;
  height: 100%;
  max-width: 100%;
}
.pp-runon-word {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  max-width: 100%;
  word-break: keep-all;
  overflow-wrap: normal;
  hyphens: none;
}
.pp-runon-cat { opacity: 0.5; font-size: 0.6em; font-style: normal; font-family: 'JetBrains Mono', monospace; }
.pp-credits {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-align: center;
  margin-top: 16px;
  opacity: 0.6;
}
.ld-poster-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.ld-poster-layouts { display: flex; gap: 6px; }
.ld-poster-layout-btn {
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--ink);
  font-family: var(--font-ui, monospace);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 0;
}
.ld-poster-layout-btn.is-active { background: var(--ink); color: var(--bg); }
.ld-poster-print {
  padding: 10px 18px;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  font-family: var(--font-ui, monospace);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: 0;
}
.ld-poster-print:hover { background: var(--accent); border-color: var(--accent); }

.share-toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 22px;
  font-family: var(--font-ui, monospace);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  z-index: 200;
  animation: toastIn 0.25s cubic-bezier(.2,.7,.2,1);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ─────────────────────────────────────────────────────────
   Print — poster export
   ───────────────────────────────────────────────────────── */
@media print {
  @page { size: A3 portrait; margin: 24mm; }
  body > *:not(.ld-modal-backdrop) { display: none !important; }
  .ld-modal-backdrop { position: static; background: transparent; backdrop-filter: none; padding: 0; }
  .ld-modal-backdrop > * { box-shadow: none; }
  .ld-modal { max-width: 100% !important; padding: 0 !important; border: none !important; max-height: none !important; }
  .ld-modal > *:not(.ld-poster-preview) { display: none !important; }
  .ld-poster-preview {
    max-height: none !important;
    aspect-ratio: auto;
    width: 100%;
    height: 100vh;
    margin: 0;
    border: 1.5px solid #1a1a1a;
  }
  .ld-poster-inner { padding: 32mm 24mm; }
  .pp-word, .pp-stack-word, .pp-runon { font-size: 64pt !important; }
}

/* ─────────────────────────────────────────────────────────
   Mobile
   ───────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .fc-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .fc-header { font-size: 9px; }
  .ld-actions { padding: 8px; flex-wrap: wrap; }
  .ld-action { padding: 6px 10px; }
  .stage-face { padding: 14px 12px; }
}


/* ─────────────────────────────────────────────────────────
   Modals (About, Poster) — restored
   ───────────────────────────────────────────────────────── */
.ld-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12, 12, 12, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: ldModalIn 0.18s ease-out;
}
@keyframes ldModalIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.ld-modal {
  position: relative;
  background: var(--bg, #ebe7df);
  color: var(--ink, #0c0c0c);
  border: 1.5px solid var(--ink, #0c0c0c);
  padding: 36px clamp(28px, 4vw, 48px);
  max-width: 560px;
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.4);
}
.ld-modal-wide { max-width: 760px; }
.ld-modal p { margin-bottom: 14px; }
.ld-modal p:last-of-type { margin-bottom: 0; }
.ld-modal em { font-style: italic; }
.ld-modal strong { font-weight: 600; }
.ld-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
  opacity: 0.55;
  padding: 4px 8px;
  transition: opacity 0.15s;
}
.ld-modal-close:hover { opacity: 1; }
.ld-eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.6;
  margin-bottom: 8px;
}
.ld-modal-title {
  font-family: 'Antonio', 'Oswald', sans-serif;
  font-weight: 700;
  font-size: clamp(1.8rem, 3.4vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin-bottom: 18px;
}
.ld-modal-rule {
  border: none;
  border-top: 1px solid var(--ink);
  opacity: 0.3;
  margin: 20px 0 16px;
}
.ld-modal kbd {
  display: inline-block;
  padding: 2px 7px;
  font-family: 'JetBrains Mono', 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  vertical-align: baseline;
}
.ld-keymap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 18px;
  font-size: 13px;
}
.ld-keymap dt { white-space: nowrap; }
.ld-keymap dd { opacity: 0.85; }

.ld-credit {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
  margin-top: 22px;
  opacity: 0.55;
}
.ld-credit a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s;
}
.ld-credit a:hover { color: var(--accent); }


/* ─────────────────────────────────────────────────────────
   Semantic color chip (Face cards)
   ───────────────────────────────────────────────────────── */
.fc-card-head-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.fc-chip {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18);
  flex-shrink: 0;
  transition: background 0.35s cubic-bezier(.2,.7,.2,1);
}
