/* Rhyme Radar — refreshed 2026-05-08
 *
 * Off-white paper, warm dark ink, single burgundy accent.
 * Serif display, hairline rules, typography-forward.
 * Sidebar with rhyme-type filters and lookup history.
 *
 * Aesthetic: vault-pulse / night-gazette (2026-05-08)
 * Author: Virgil
 */

:root {
  /* Palette */
  --paper: #f6f2e9;
  --paper-shade: #ede8d9;
  --paper-deep: #e0d7bf;

  --ink: #1a1814;           /* warm dark — primary text */
  --ink-mid: #3a3428;        /* medium dark — secondary */
  --ink-mute: #6a5a48;       /* faded warm — tertiary */
  --ink-ghost: #a89a7a;      /* very faint — rules, hints */

  --perfect: #7a2a2a;        /* burgundy — perfect rhymes */
  --near: #8a4a3a;           /* deeper sienna — near rhymes */
  --assonance: #7a7a6a;      /* muted gray-brown — assonance */
  --consonance: #8a7a7a;     /* dusty taupe — consonance */

  /* Typography */
  --font-body: "EB Garamond", Georgia, "Hoefler Text", serif;
  --font-mono: "IBM Plex Mono", "Menlo", Consolas, monospace;

  /* Spacing */
  --gutter: 2rem;
  --max-width: 980px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;

  /* Very subtle paper grain */
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 2px,
      rgba(180, 160, 120, 0.015) 2px, rgba(180, 160, 120, 0.015) 3px),
    repeating-linear-gradient(90deg, transparent, transparent 3px,
      rgba(180, 160, 120, 0.01) 3px, rgba(180, 160, 120, 0.01) 4px);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ */
/* Masthead                                                            */
/* ------------------------------------------------------------------ */

.masthead {
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink-ghost);
  padding: 1.5rem var(--gutter) 1rem;
  margin-bottom: 1.5rem;
}

.masthead-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
}

.title {
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: 0.02em;
  margin: 0 0 0.4rem;
  color: var(--ink);
}

.subtitle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-mute);
  margin: 0;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------------ */
/* Seed input                                                          */
/* ------------------------------------------------------------------ */

.radar-shell {
  flex: 1;
  padding: 0 var(--gutter) 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.seed-form {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0 1.5rem;
  flex-wrap: wrap;
  order: -1; /* puts it at top */
}

.seed-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.seed-input {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink-ghost);
  padding: 0.25rem 0.5rem;
  min-width: 12rem;
  max-width: 18rem;
  text-align: center;
  outline: none;
  transition: border-color 200ms ease;
}

.seed-input:focus {
  border-bottom-color: var(--perfect);
}

.seed-input::placeholder {
  color: var(--ink-ghost);
  font-style: italic;
}

.seed-hint {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-ghost);
  font-style: normal;
  min-width: 12rem;
}

.seed-hint.error {
  color: var(--perfect);
}

/* ------------------------------------------------------------------ */
/* Radar canvas & sidebar                                              */
/* ------------------------------------------------------------------ */

.radar-main-wrap {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 2rem;
  align-items: start;
}

.radar-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 600px;
  margin: 0 auto;
}

.radar-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.legend {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-mute);
  pointer-events: none;
  text-align: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.legend-item::before {
  content: "";
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
}

.legend-perfect::before    { background: var(--perfect); }
.legend-near::before       { background: var(--near); }
.legend-assonance::before  { background: var(--assonance); }
.legend-consonance::before { background: var(--consonance); }

/* ---- Sidebar ---- */
.radar-sidebar {
  border-left: 1px solid var(--ink-ghost);
  padding-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
  font-size: 0.85rem;
  line-height: 1.6;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.sidebar-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  margin-bottom: 0.2rem;
}

.filter-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-btn {
  padding: 0.35rem 0.5rem;
  background: transparent;
  border: 1px solid var(--ink-ghost);
  border-radius: 2px;
  color: var(--ink-mute);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-style: italic;
  cursor: pointer;
  transition: all 150ms ease;
}

.filter-btn:hover {
  border-color: var(--ink-mid);
  color: var(--ink-mid);
}

.filter-btn.active {
  border-color: var(--perfect);
  color: var(--perfect);
  background: rgba(122, 42, 42, 0.08);
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history-item {
  padding: 0.2rem 0;
  color: var(--ink-mute);
  font-style: italic;
  cursor: pointer;
  transition: color 150ms ease;
  word-break: break-word;
}

.history-item:hover {
  color: var(--perfect);
}

/* ------------------------------------------------------------------ */
/* Breadcrumb path                                                     */
/* ------------------------------------------------------------------ */

.breadcrumb {
  border-top: 1px dotted var(--ink-ghost);
  padding: 1.5rem 0 0.5rem;
  margin-top: 2rem;
  min-height: 3rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.breadcrumb-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  flex-shrink: 0;
}

.breadcrumb-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.8rem;
  padding: 0;
  margin: 0;
  font-style: italic;
  color: var(--ink);
  font-size: 1.05rem;
}

.breadcrumb-list li:not(:last-child)::after {
  content: "→";
  margin-left: 0.8rem;
  color: var(--ink-ghost);
  font-style: normal;
}

.breadcrumb-list li.current {
  color: var(--perfect);
  font-weight: 500;
}

.breadcrumb-list li {
  cursor: pointer;
  transition: color 150ms ease;
}

.breadcrumb-list li:hover:not(.current) {
  color: var(--perfect);
}

/* ------------------------------------------------------------------ */
/* Keyboard hint                                                       */
/* ------------------------------------------------------------------ */

.kbd-hint {
  margin-top: 0.75rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-ghost);
  letter-spacing: 0.08em;
}

.kbd-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.kbd-hint kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  margin: 0 0.1rem;
  background: var(--paper-shade);
  border: 1px solid var(--ink-ghost);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-mute);
  line-height: 1;
}

.audio-toggle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.8rem;
  color: var(--ink-mute);
  background: transparent;
  border: 1px solid var(--ink-ghost);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  cursor: pointer;
  transition: all 200ms ease;
}

.audio-toggle:hover {
  color: var(--perfect);
  border-color: var(--perfect);
}

.audio-toggle.on {
  color: var(--perfect);
  border-color: var(--perfect);
  background: rgba(107, 45, 45, 0.06);
}

/* ------------------------------------------------------------------ */
/* Colophon                                                            */
/* ------------------------------------------------------------------ */

.colophon {
  border-top: 1px solid var(--ink-ghost);
  padding: 1.5rem var(--gutter);
  margin-top: auto;
  text-align: center;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--ink-mute);
}

.colophon p {
  max-width: var(--max-width);
  margin: 0 auto;
}

.colophon-date {
  color: var(--ink-ghost);
}

/* ------------------------------------------------------------------ */
/* Motion                                                              */
/* ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ------------------------------------------------------------------ */
/* Mobile — ≤ 768px                                                    */
/* ------------------------------------------------------------------ */

@media (max-width: 768px) {
  :root {
    --gutter: 1rem;
  }

  html, body {
    font-size: 15px;
  }

  .masthead {
    padding: 1rem var(--gutter) 0.75rem;
    margin-bottom: 1rem;
  }

  .title {
    font-size: clamp(1.8rem, 5vw, 2.4rem);
  }

  /* Seed form: stack label + input vertically */
  .seed-form {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0 1rem;
  }

  .seed-label {
    display: none;
  }

  .seed-input {
    font-size: 1.2rem;
    min-width: 0;
    width: min(100%, 18rem);
    max-width: 100%;
    padding: 0.4rem 0.5rem;
  }

  .seed-hint {
    min-width: 0;
    width: 100%;
    text-align: center;
    font-size: 0.65rem;
  }

  /* Sidebar goes below radar on mobile */
  .radar-main-wrap {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .radar-sidebar {
    border-left: none;
    border-top: 1px solid var(--ink-ghost);
    padding-left: 0;
    padding-top: 1rem;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2rem;
  }

  .sidebar-section {
    flex: 1;
    min-width: 120px;
  }

  /* Keyboard hint: hide on mobile */
  .kbd-hint > span {
    display: none;
  }

  .audio-toggle {
    padding: 0.4rem 1rem;
    font-size: 0.9rem;
    min-height: 40px;
  }

  .kbd-hint {
    justify-content: center;
    margin-top: 0.75rem;
  }

  .breadcrumb {
    margin-top: 1rem;
    padding: 0.75rem 0 0.5rem;
  }

  .colophon {
    padding: 1rem var(--gutter);
    font-size: 0.7rem;
  }
}

/* ------------------------------------------------------------------ */
/* Small phones — ≤ 480px                                              */
/* ------------------------------------------------------------------ */

@media (max-width: 480px) {
  .title {
    font-size: clamp(1.6rem, 8vw, 2.2rem);
  }

  .subtitle {
    font-size: 0.85rem;
  }

  .legend {
    font-size: 0.65rem;
    gap: 0.3rem;
  }

  .legend-item::before {
    width: 0.5rem;
    height: 0.5rem;
  }

  .seed-input {
    font-size: 1.15rem;
  }

  .breadcrumb-list {
    font-size: 0.9rem;
  }

  .sidebar-section {
    min-width: 100px;
  }
}
