/*
Impeccable direction contract (seed key 31280ff2, own-world grounded candidate)
THESIS: turning a book into a word list should feel like an extension of
  reading it, not like operating a data tool -- warmth carries over from
  the book into the surface.
OWN-WORLD: warm cream page, gouache/colored-pencil texture, rounded
  hand-drawn shapes and soft lift shadows; a friendly rounded display face
  for headline moments, a warm humanist sans for everything people read or
  click, and a precise tabular mono reserved only for the numbers that are
  real measurements (word counts, percentages, ranks).
STORY: a visitor sees a warm, legible page that explains the mechanism in
  plain words, drops in a book without hunting for the control, and reads
  a results table where the data still looks like data.
FIRST VIEWPORT: a rounded headline beside a simple line-drawn open-book
  illustration, plain-language claim, honest scope tags, and the upload
  card itself, no scroll required to act.
FORM: Storybook Illustration -- own grounded direction (assigned index 6),
  replacing the "Emigre Bitmap Specimen" world after user feedback that it
  read as technical rather than friendly.
FINISH: unreviewed and undocumented is unfinished; this build ends with
  the finish review, the verdict, and DESIGN.md.
*/

:root {
  color-scheme: light dark;
  --cream: #faf3e7;
  --panel: #fffdf8;
  --ink: #2b231b;
  --muted: #6b5d4f;
  --coral: #e8623d;
  --coral-ink: #fffdf8;
  --gold: #d9a441;
  --gold-ink: #2b231b;
  --teal: #4e8c86;
  --teal-ink: #fffdf8;
  --rule: rgba(43, 35, 27, 0.12);
  --shadow-soft: 0 8px 24px rgba(43, 35, 27, 0.1);
  --shadow-lift: 0 4px 14px rgba(43, 35, 27, 0.16);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --teal-text: #2f6560;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch' result='t'/%3E%3CfeColorMatrix in='t' type='matrix' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1.8 -0.45'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cream: #2b2118;
    --panel: #362a1f;
    --ink: #f5ead9;
    --muted: #c2af98;
    --coral: #f0764f;
    --coral-ink: #2b2118;
    --gold: #e8bb5c;
    --gold-ink: #2b2118;
    --teal: #6fada6;
    --teal-ink: #182220;
    --teal-text: #8ec4bd;
    --rule: rgba(245, 234, 217, 0.14);
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lift: 0 4px 14px rgba(0, 0, 0, 0.38);
  }
}

:root[data-theme="dark"] {
  --cream: #2b2118;
  --panel: #362a1f;
  --ink: #f5ead9;
  --muted: #c2af98;
  --coral: #f0764f;
  --coral-ink: #2b2118;
  --gold: #e8bb5c;
  --gold-ink: #2b2118;
  --teal: #6fada6;
  --teal-ink: #182220;
  --rule: rgba(245, 234, 217, 0.14);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lift: 0 4px 14px rgba(0, 0, 0, 0.38);
}

@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: url("fonts/baloo2-var.woff2") format("woff2");
}

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/nunito-var.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/jetbrains-mono-400.woff2") format("woff2");
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

.display {
  font-family: "Baloo 2", "Nunito", sans-serif;
}

.data {
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

/* Gouache-paper grain: a subtle noise layer over otherwise-flat panels so
   surfaces read as textured stock rather than clean digital fills. */
.textured { position: relative; }

.textured::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--grain);
  opacity: 0.13;
  mix-blend-mode: multiply;
  pointer-events: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .textured::after { mix-blend-mode: overlay; opacity: 0.18; }
}

:root[data-theme="dark"] .textured::after { mix-blend-mode: overlay; opacity: 0.18; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* ---- header ---- */

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0 1.5rem;
  margin-bottom: 1.5rem;
}

.wordmark {
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  font-weight: 700;
  color: var(--coral);
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--teal-text);
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
}

.nav-link:hover {
  text-decoration: underline;
}

.tagline {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

/* ---- hero ---- */

.hero {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(1.5rem, 4vw, 2.75rem);
  margin-bottom: 2rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}

.book-illustration {
  width: 5.5rem;
  height: auto;
  margin-bottom: 1rem;
}

.hero-headline {
  font-weight: 700;
  font-size: clamp(2.2rem, 5.5vw, 3.4rem);
  line-height: 1.08;
  margin: 0 0 1rem;
}

.hero-headline .accent { color: var(--coral); }

.hero-claim {
  max-width: 34rem;
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--cream);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-size: 1rem;
  border-radius: var(--radius-pill);
  border: none;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: var(--coral);
  color: var(--coral-ink);
  box-shadow: var(--shadow-lift);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(43, 35, 27, 0.22);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.btn-secondary {
  background: var(--cream);
  color: var(--ink);
}

.btn-secondary:hover {
  transform: translateY(-2px);
}

/* ---- how it works ---- */

.modules {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 2rem;
  overflow: hidden;
}

.module {
  padding: clamp(1.5rem, 3vw, 2rem);
}

.module + .module {
  border-left: 1px solid var(--rule);
}

.module-icon {
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.75rem;
}

.module h3 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0 0 0.6rem;
  font-size: 1.15rem;
  font-weight: 800;
}

.module-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--teal-ink);
  background: var(--teal);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.55rem;
}

.module p {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.module code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  background: var(--cream);
  color: var(--ink);
  border-radius: 5px;
  padding: 0.05rem 0.35rem;
  font-size: 0.85em;
}

/* ---- tool ---- */

.hero-tool {
  border-left: 1px solid var(--rule);
  padding-left: clamp(1.5rem, 3vw, 2.25rem);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 8rem;
  border: 2px dashed color-mix(in srgb, var(--coral) 55%, transparent);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  transition: background 0.15s ease, border-color 0.15s ease;
  font-weight: 700;
  color: var(--muted);
}

.dropzone-icon {
  width: 2rem;
  height: 2rem;
  color: var(--coral);
}

.dropzone.dragover {
  background: color-mix(in srgb, var(--coral) 12%, transparent);
  border-style: solid;
}

.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.language-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  max-width: 14rem;
  margin-bottom: 1.25rem;
}

.filters {
  margin-bottom: 1.25rem;
}

.filters summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--teal-text);
}

.filters[open] summary { margin-bottom: 1rem; }

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.9rem;
}

.filters-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.filters-grid label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

input[type="number"],
select {
  padding: 0.55rem 0.7rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  font-family: "Nunito", sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
}

button { font: inherit; }

#status {
  min-height: 1.2rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: 1rem;
}

#status.error { color: var(--coral); }

/* ---- results ---- */

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.results-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 0;
}

.table-wrap {
  background: var(--panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 0.65rem 1rem;
  white-space: nowrap;
}

thead th {
  background: color-mix(in srgb, var(--teal) 16%, var(--panel));
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  position: sticky;
  top: 0;
}

tbody tr {
  border-top: 1px solid var(--rule);
}

tbody td.num {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

tbody td.word {
  font-weight: 800;
}

tbody td.example {
  color: var(--muted);
  font-style: italic;
}

.pos-tag {
  display: inline-block;
  background: var(--gold);
  color: var(--gold-ink);
  border-radius: var(--radius-pill);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
}

/* ---- footer ---- */

.site-footer {
  padding-top: 1.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-tool {
    border-left: none;
    border-top: 1px solid var(--rule);
    padding-left: 0;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
  }
}

@media (max-width: 640px) {
  .modules { grid-template-columns: 1fr; }
  .module + .module {
    border-left: none;
    border-top: 1px solid var(--rule);
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 0.25rem 0 0.75rem;
    margin-bottom: 0.75rem;
  }
  .hero { padding: clamp(1.25rem, 4vw, 2.75rem); }
  .book-illustration { width: 4rem; margin-bottom: 0.5rem; }
  .hero-headline { margin-bottom: 0.6rem; }
  .hero-claim { margin-bottom: 1rem; }
  .tag-row { margin-bottom: 0.85rem; }
  .dropzone { min-height: 6rem; padding: 1rem; margin-bottom: 1rem; }
  .language-field { margin-bottom: 0.85rem; }
}
