/*
 * Pecora Coffee — site styles.
 * Palette, fonts and wood come from the Pecora Sensory Trainer.
 * Principles (see design-principles.md):
 *   - Content first, semantic HTML, works without JavaScript (Lea Verou)
 *   - Visuals generated from the subject's own data: the tasting fingerprint (Talia Cotton)
 *   - Big confident type, one motion system, restraint (Tanish Mittal)
 *   - A clear numbered structure that maps the site (Marek Vataha)
 * Dark mode follows the device setting. There is no toggle on purpose.
 */

/* ---------- Fonts (self-hosted, same files as the trainer) ---------- */
@font-face { font-family: "AddingtonCF"; src: url("fonts/AddingtonCF-Regular.otf") format("opentype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "AddingtonCF"; src: url("fonts/AddingtonCF-RegularItalic.otf") format("opentype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "AddingtonCF"; src: url("fonts/AddingtonCF-Medium.otf") format("opentype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "ChopinScript"; src: url("fonts/ChopinScript.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("fonts/google/inter-400-latin.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("fonts/google/inter-500-latin.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("fonts/google/inter-600-latin.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;
  --ink: #270307;
  --ink-soft: #4a2a2e;
  --cream: #efe9db;
  --tan: #ccba94;
  --tan-deep: #b9a67e;
  --ivory: #f5f0d8;
  --surface: #f8f4ea;
  --surface-2: #ece4d3;
  --text-soft: #6e6357;
  --accent: #8a5a2b;
  --field: #fffdf6;
  --band: #270307;
  --band-text: #f5f0d8;
  --band-text-soft: rgba(245, 240, 216, 0.8);
  --band-accent: #ccba94;
  --line: color-mix(in oklab, var(--ink) 12%, transparent);
  --rule: color-mix(in oklab, var(--ink) 85%, transparent);

  --font-display: "AddingtonCF", "Times New Roman", Georgia, serif;
  --font-ui: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-script: "ChopinScript", "AddingtonCF", cursive;

  /* One motion system: every hover, reveal and draw uses these. */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --fast: 200ms;
  --slow: 900ms;

  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 48px; --s6: 72px; --s7: 112px;
  --max: 1160px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font-family: var(--font-ui); font-size: 17px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
::selection { background: #d8cc93; color: var(--ink); }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hidden { display: none; }
.wrap { max-width: var(--max); margin: 0 auto; padding-inline: max(24px, env(safe-area-inset-left, 0px)) max(24px, env(safe-area-inset-right, 0px)); }
.skip { position: absolute; left: 16px; top: -60px; z-index: 100; background: var(--ink); color: var(--cream); padding: 10px 16px; border-radius: 3px; text-decoration: none; }
.skip:focus { top: 12px; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; color: var(--ink); letter-spacing: -0.01em; text-wrap: balance; margin: 0 0 var(--s2); }
h1 { font-size: clamp(2.8rem, 6.2vw, 5.2rem); line-height: 0.98; letter-spacing: -0.02em; }
h1 em, h2 em { font-style: italic; color: var(--accent); }
h2 { font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1.05; }
h3 { font-size: 1.5rem; line-height: 1.2; }
p { margin: 0 0 var(--s2); text-wrap: pretty; }
.lede { font-size: 1.2rem; color: var(--text-soft); max-width: 32em; margin-bottom: var(--s4); }

/* Section index labels: "01 — Journal" (the numbers match the menu) */
.label {
  display: flex; align-items: baseline; gap: 12px; margin: 0 0 var(--s3);
  font-size: 12px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-soft);
}
.label b { font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: 1.35rem; letter-spacing: 0; text-transform: none; color: var(--accent); }

/* ---------- Buttons and links ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 14px 24px;
  font: inherit; font-size: 13px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; text-decoration: none;
  border: 0; border-radius: 3px; cursor: pointer; background: var(--ink); color: var(--ivory);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.btn:hover { background: var(--accent); color: var(--ivory); }
.btn.line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.btn.line:hover { background: var(--ink); color: var(--cream); }
.btn .arrow, .more .arrow { display: inline-block; transition: transform var(--fast) var(--ease); }
.btn:hover .arrow, .more:hover .arrow, a:hover > .arrow { transform: translateX(4px); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.more { font-size: 15px; font-weight: 500; color: var(--accent); text-decoration: none; white-space: nowrap; }
.more:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Masthead: a wood plank with a numbered menu and a Sensory tab ---------- */
.site-header { position: sticky; top: 0; z-index: 50; color: var(--wood-text); }
.site-header .wrap { display: flex; align-items: center; gap: var(--s4); height: 80px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--wood-text); text-shadow: 0 1px 1px rgba(40, 20, 8, 0.35); margin-right: auto; }
.brand img { height: 46px; width: auto; filter: invert(1) hue-rotate(180deg) brightness(1.05); }
.brand span { font-family: var(--font-script); font-size: 42px; line-height: 1; }
.nav ol { display: flex; gap: 28px; list-style: none; margin: 0; padding: 0; }
.nav a {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 0; text-decoration: none;
  font-size: 13px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--wood-text-soft);
  border-bottom: 1px solid transparent; transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.nav a i { font-family: var(--font-display); font-size: 15px; letter-spacing: 0; text-transform: none; opacity: 0.8; }
.nav a:hover { color: var(--wood-text); border-bottom-color: var(--wood-text-soft); }
.nav a[aria-current="page"] { color: var(--wood-text); border-bottom-color: var(--wood-text); }
/* The tab rises from the page into the wood, like a folder tab */
.tab {
  align-self: flex-end; display: inline-flex; align-items: center; gap: 10px; height: 52px; padding: 0 18px 0 12px;
  margin-bottom: -3px; position: relative; z-index: 1; text-decoration: none;
  background: var(--cream); color: var(--ink); border-radius: 8px 8px 0 0;
  font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  box-shadow: 0 -1px 0 rgba(255, 250, 240, 0.4);
  transition: background var(--fast) var(--ease);
}
.tab img { width: 30px; height: 30px; border-radius: 7px; }
.tab .long { margin-left: -4px; }
.tab:hover { background: var(--surface); }

/* ---------- Hero ---------- */
.hero { padding: var(--s6) 0 var(--s6); }
.hero .wrap { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: var(--s5); align-items: center; }
.hero h1 .w { display: inline-block; animation: rise var(--slow) var(--ease) both; animation-delay: calc(var(--i) * 55ms); }
@keyframes rise { from { opacity: 0; transform: translateY(0.35em); } }
.hero .where { font-size: 12px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-soft); margin-bottom: var(--s3); }

/* Tasting fingerprint: rings drawn from a coffee's 9-point cupping scores */
.fingerprint { margin: 0; display: grid; gap: var(--s2); justify-items: center; }
.fp-pick { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 20px; border: 0; padding: 0; margin: 0; }
.fp-pick legend { width: 100%; text-align: center; font-size: 12px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-soft); margin-bottom: 6px; }
.fp-pick label { cursor: pointer; font-family: var(--font-display); font-size: 1.15rem; color: var(--text-soft); padding: 2px 0; border-bottom: 1px solid transparent; transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease); }
.fp-pick label:hover { color: var(--ink); }
.fp-pick input:checked + label { color: var(--ink); border-bottom-color: var(--accent); }
.fp-pick input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 3px; }
.fp-stack { display: grid; width: min(100%, 460px); }
.fp-stack > div { grid-area: 1 / 1; visibility: hidden; opacity: 0; transition: opacity var(--fast) var(--ease); }
.fp-stack > div:first-child { visibility: visible; opacity: 1; }
.fp-stack svg { width: 100%; height: auto; overflow: visible; color: var(--ink); }
.fp-stack .ring { fill: none; stroke: currentColor; stroke-width: 0.8; stroke-linecap: round; }
.fp-stack .ring.major { stroke-width: 1.4; }
.fp-stack .ring.outer { stroke: var(--accent); stroke-width: 2.2; }
.fp-stack .tick { stroke: var(--text-soft); stroke-width: 1; }
.fp-stack .attr { font-family: var(--font-ui); font-size: 10.5px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; fill: var(--text-soft); }
.fp-stack .score { font-family: var(--font-display); font-size: 17px; fill: var(--ink); }
.fp-stack .mean { font-family: var(--font-display); font-size: 40px; fill: var(--ink); }
.fp-stack .mean-l { font-family: var(--font-ui); font-size: 9.5px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; fill: var(--text-soft); }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.fingerprint figcaption { text-align: center; font-size: 14px; color: var(--text-soft); max-width: 30em; }
.fingerprint figcaption b { font-family: var(--font-display); font-weight: 400; font-size: 1.15rem; color: var(--ink); }

/* ---------- Seed-to-cup strip ---------- */
.strip { border-block: 1px solid var(--rule); overflow: hidden; padding: 14px 0; }
.strip-track { display: flex; width: max-content; animation: slide 60s linear infinite; }
.strip:hover .strip-track { animation-play-state: paused; }
.strip ol { display: flex; list-style: none; margin: 0; padding: 0 0 0 48px; gap: 48px; }
.strip li { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; font-family: var(--font-display); font-style: italic; font-size: 1.6rem; color: var(--ink); }
.strip li span { font-family: var(--font-ui); font-style: normal; font-size: 11px; font-weight: 600; letter-spacing: 0.18em; color: var(--accent); }
@keyframes slide { to { transform: translateX(-50%); } }

/* ---------- Sections ---------- */
section { padding: var(--s7) 0; }
.alt { background: var(--surface); }
.head { display: flex; justify-content: space-between; align-items: end; gap: var(--s3); margin-bottom: var(--s4); }
.head h2 { margin: 0; }

/* Journal index: numbered, dated, with read times */
.index { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.index a {
  display: grid; grid-template-columns: 3.5rem 10rem 1fr auto; gap: var(--s3); align-items: baseline;
  padding: var(--s3) 0; border-bottom: 1px solid var(--line); text-decoration: none;
}
.index .n { font-family: var(--font-display); font-style: italic; font-size: 1.4rem; color: var(--accent); }
.index .when { font-size: 13px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.index .t { font-family: var(--font-display); font-size: 1.7rem; line-height: 1.15; display: block; }
.index .s { display: block; color: var(--text-soft); font-size: 0.97rem; margin-top: 4px; }
.index .r { display: block; font-size: 13px; font-weight: 500; color: var(--accent); margin-top: 8px; font-variant-numeric: tabular-nums; }
.index .tag { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-soft); white-space: nowrap; }
.index .tag em { font-style: normal; color: var(--accent); }
.index a:hover .t { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }

/* Journal placeholder until the first entries are published */
.soon { display: grid; gap: var(--s3); max-width: 46em; padding-top: var(--s4); border-top: 1px solid var(--rule); }
.soon p { margin: 0; font-size: 1.15rem; color: var(--text-soft); }

/* Learn: the Sensory Trainer */
.learn { display: grid; grid-template-columns: 0.75fr 1.25fr; gap: var(--s6); align-items: start; }
.learn-card { display: grid; gap: var(--s2); justify-items: start; position: sticky; top: 120px; }
.learn-card img { width: min(100%, 300px); border-radius: 22%; box-shadow: 0 24px 48px -28px rgba(39, 3, 7, 0.55); }
.learn-card .url { font-size: 14px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.modules { list-style: none; margin: var(--s4) 0; padding: 0; border-top: 1px solid var(--rule); }
.modules li { display: grid; grid-template-columns: 12rem 1fr; gap: var(--s3); padding: 18px 0; border-bottom: 1px solid var(--line); }
.modules b { font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; line-height: 1.25; }
.modules span { color: var(--text-soft); font-size: 0.97rem; }

/* About: the Stray Sheep band */
.dark { color: var(--band-text); }
.dark h2, .dark blockquote { color: var(--band-text); }
.dark p { color: var(--band-text-soft); }
.dark .label { color: var(--band-text-soft); }
.dark .label b, .dark .more { color: var(--band-accent); }
.story { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: var(--s6); align-items: center; }
.story-art img { width: 100%; max-width: 460px; margin-inline: auto; }
.story blockquote { margin: 0 0 var(--s3); font-family: var(--font-display); font-style: italic; font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1.25; }

.meet { display: grid; grid-template-columns: 0.7fr 1.3fr; gap: var(--s6); align-items: center; }
.meet .portrait { aspect-ratio: 4 / 5; overflow: hidden; border-radius: 2px; box-shadow: 12px 12px 0 -1px var(--surface-2), 12px 12px 0 0 var(--tan-deep); }
.meet .portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 80% center; }
.meet p { color: var(--text-soft); max-width: 34em; }

/* Newsletter */
.signup { display: grid; grid-template-columns: 170px 1fr; gap: var(--s5); align-items: center; border-block: 1px solid var(--rule); padding: var(--s6) 0; }
.signup-art { width: 170px; height: 170px; border-radius: 50%; background: var(--tan); padding: 18px; overflow: hidden; }
.signup-art img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.signup p { color: var(--text-soft); max-width: 34em; }
.signup form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: var(--s3); }
.signup input[type="email"] {
  flex: 0 1 340px; min-height: 48px; padding: 12px 16px; border-radius: 3px; border: 1px solid var(--tan-deep);
  background: var(--field); color: var(--ink); font: inherit; font-size: 15px;
}
.signup input::placeholder { color: var(--text-soft); }

/* Prose pages */
.page-hero { padding: var(--s6) 0 var(--s4); }
.prose { max-width: 700px; }
.prose h2 { margin-top: var(--s6); }
.prose p { color: var(--ink-soft); }
.banner { aspect-ratio: 21 / 9; overflow: hidden; border-radius: 2px; margin: 0 0 var(--s1); }
.banner img { width: 100%; height: 100%; object-fit: cover; }
.caption { font-size: 13px; color: var(--text-soft); margin: 0 0 var(--s5); }
.inline-art { float: right; width: 42%; max-width: 260px; margin: 6px 0 var(--s2) 28px; border-radius: 2px; background: var(--band); padding: 12px; }
.inline-portrait { float: right; width: 40%; max-width: 240px; margin: 6px 0 var(--s2) 28px; border-radius: 2px; overflow: hidden; }
.clear { clear: both; }

/* Footer: a thin wood strip */
.site-footer { padding: var(--s5) 0; font-size: 14px; color: var(--wood-text-soft); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; align-items: center; }
.site-footer .who { display: flex; gap: 14px; align-items: center; }
.site-footer .who img { width: 44px; height: auto; filter: invert(1) hue-rotate(180deg); }
.site-footer strong { color: var(--wood-text); font-weight: 600; }
.site-footer nav { display: flex; gap: 22px; flex-wrap: wrap; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--wood-text); text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Wood (same grain recipe as the trainer) ---------- */
:root {
  /* Real-looking planks rendered by tools/wood (see render.sh) */
  --wood: url("images/wood.jpg");
  /* a light oil finish: soft sheen on top, a little shade for legible text */
  --wood-sheen: linear-gradient(180deg, rgba(255, 244, 224, 0.22), rgba(255, 244, 224, 0.04) 40%, rgba(0, 0, 0, 0.10));
  --wood-shade: linear-gradient(rgba(64, 34, 14, 0.24), rgba(64, 34, 14, 0.24));
  --wood-stain: linear-gradient(180deg, rgba(30, 13, 6, 0.66), rgba(20, 8, 4, 0.74));
  --wood-text: #fdf6e8;
  --wood-text-soft: rgba(253, 246, 232, 0.9);
}
.site-header, .site-footer {
  background: var(--wood-sheen), var(--wood-shade), var(--wood) 0 -250px / 2000px 720px repeat-x, #7a5233;
}
.site-footer { background-position: 0 0, 0 0, -640px -420px, 0 0; }
.site-header { border-bottom: 3px solid rgba(40, 20, 8, 0.35); box-shadow: inset 0 1px 0 rgba(255, 250, 240, 0.35); }
.site-footer { border-top: 3px solid rgba(40, 20, 8, 0.35); }
/* The Stray Sheep section: the same solid slab under a dark espresso stain */
.dark { background: var(--wood-stain), var(--wood-sheen), var(--wood) center / cover no-repeat, var(--band); }

/* ---------- Dark mode: follows the device, same palette as the trainer ---------- */
@media (prefers-color-scheme: dark) {
  :root {
/*DARK-TOKENS-START*/
    --ink: #f2ead8;
    --ink-soft: #d9ccb6;
    --cream: #171011;
    --tan: #cbb38c;
    --tan-deep: #7a6448;
    --ivory: #1c1314;
    --surface: #231a1b;
    --surface-2: #33282a;
    --text-soft: #b8ab98;
    --accent: #d9a46a;
    --field: #241b1c;
    --band: #0e0909;
    --band-accent: #dcaa72;
/*DARK-TOKENS-END*/
  }
}
@media (prefers-color-scheme: dark) {
  :root {
/*DARK-WOOD-START*/
    --wood-sheen: linear-gradient(180deg, rgba(255, 236, 205, 0.10), rgba(255, 236, 205, 0.02) 40%, rgba(0, 0, 0, 0.16));
    --wood-shade: linear-gradient(rgba(22, 11, 5, 0.50), rgba(22, 11, 5, 0.50));
    --wood-stain: linear-gradient(180deg, rgba(14, 6, 3, 0.78), rgba(8, 4, 2, 0.84));
/*DARK-WOOD-END*/
  }
}
@media (prefers-color-scheme: dark) {
/*DARK-RULES-START*/
  ::selection { background: #6b5a2c; color: var(--ink); }
  .learn-card img { box-shadow: 0 24px 48px -28px rgba(0, 0, 0, 0.9); }
/*DARK-RULES-END*/
}

/* ---------- Phones ---------- */
@media (max-width: 900px) {
  section { padding: var(--s6) 0; }
  .hero { padding: var(--s5) 0; }
  .hero .wrap, .story, .meet, .learn { grid-template-columns: 1fr; gap: var(--s5); }
  .learn-card { position: static; }
  .learn-card img { width: 160px; }
  .meet .portrait { max-width: 340px; }
  .head { flex-direction: column; align-items: start; }
  .index a { grid-template-columns: 2.25rem 1fr; gap: 6px 14px; }
  .index .when, .index .tag { grid-column: 2; }
  .index .when { order: 3; }
  .index .tag { order: 4; }
  .modules li { grid-template-columns: 1fr; gap: 4px; }
  .signup { grid-template-columns: 1fr; justify-items: start; }
  .signup-art { width: 120px; height: 120px; }
  .inline-art, .inline-portrait { float: none; width: 100%; max-width: 320px; margin: 0 0 var(--s3); }
  /* Menu becomes a second row inside the wood: no hamburger, nothing hidden */
  .site-header .wrap { flex-wrap: wrap; height: auto; padding-top: 10px; gap: 0 var(--s2); }
  .brand span { font-size: 34px; }
  .brand img { height: 38px; }
  .tab { height: 44px; padding: 0 12px 0 8px; margin-bottom: 0; align-self: center; border-radius: 6px; font-size: 12px; }
  .tab img { width: 26px; height: 26px; }
  .nav { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; margin-inline: -4px; }
  .nav ol { gap: 22px; padding: 8px 4px 12px; }
  html { scroll-padding-top: 130px; }
}
@media (max-width: 420px) { .tab .long { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .strip-track { width: auto; }
  .strip ol[aria-hidden] { display: none; }
  .strip ol { flex-wrap: wrap; gap: 12px 36px; padding-left: 24px; }
}
