/* danimelich.com — v4
 *
 * v4 answers Dani's review of v3, plus the editorial-layout lesson: an
 * asymmetric grid — one wide reading column and one narrow margin column — is
 * the standard solution to both "pin the contents to the right" and "there is
 * unused real estate". The margin column is not decoration; it holds the index
 * on a case study and the availability facts on the overview.
 *
 * What came back from v2, because Dani preferred it: the two-line tab (kicker
 * over serif label), the wash under the header, and the wider reading column.
 * What did NOT come back: the contrast failures those things shipped with. The
 * kickers were 2.36:1 at 10px; they now read at 11.5px and pass.
 *
 * The palette is no longer one orange. Each section owns a hue, set by
 * body[data-section] and consumed through --accent / --accent-ink, so the site
 * changes character as you move through it without any page becoming noisy.
 *
 *   1. tokens + palette   2. field   3. masthead + tabs   4. sheet + grid
 *   5. overview   6. document   7. index   8. tables + figures   9. chrome
 */

/* -------------------------------------------------- 1. tokens and palette -- */

:root {
  --paper: #FCF7EF;
  --field: #EADFCE;
  --sunken: #F5EDE1;
  --edge: #E0D2BC;
  --rule: #E8DCC9;

  --ink: #1E2530;
  --body: #4A5462;
  --muted: #616B79;        /* 5.1:1 on --paper */
  --muted-field: #4E5866;  /* 5.4:1 on --field, for masthead text */

  --shell: 78rem;
  --read: 46rem;          /* the reading column */
  --margin-col: 17rem;
  --gap: clamp(1.8rem, 4vw, 3.5rem);
  --pad: clamp(1.3rem, 3.5vw, 2.8rem);
  --gutter: clamp(1rem, 3.5vw, 2.2rem);
  --radius: 14px;
  --shadow: 0 28px 60px -38px rgba(40, 52, 68, 0.55), 0 2px 6px -3px rgba(40, 52, 68, 0.09);

  /* Default (overview): warm gold. */
  --accent: #C08A2A;
  --accent-ink: #7E570D;
  --accent-soft: rgba(192, 138, 42, 0.14);
}

body[data-section="ui-harness"]     { --accent: #6C63E0; --accent-ink: #4A40B4; --accent-soft: rgba(108, 99, 224, 0.13); }
body[data-section="stepland"]       { --accent: #188C77; --accent-ink: #0F6252; --accent-soft: rgba(24, 140, 119, 0.13); }
body[data-section="dungeon-heroes"] { --accent: #CF5A40; --accent-ink: #9C3A26; --accent-soft: rgba(207, 90, 64, 0.13); }
body[data-section="purple-pwny"]    { --accent: #A2559A; --accent-ink: #75356E; --accent-soft: rgba(162, 85, 154, 0.13); }

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1B2029;
    --field: #10141B;
    --sunken: #232A34;
    --edge: #303945;
    --rule: #2C343F;

    --ink: #F2EBE0;
    --body: #BDC7D2;
    --muted: #93A0AE;
    --muted-field: #A3B0BE;

    --accent: #E0AE55;
    --accent-ink: #EDC582;
    --accent-soft: rgba(224, 174, 85, 0.15);
    --shadow: 0 28px 60px -38px rgba(0, 0, 0, 0.9), 0 2px 6px -3px rgba(0, 0, 0, 0.5);
  }

  body[data-section="ui-harness"]     { --accent: #9C90FF; --accent-ink: #B4AAFF; --accent-soft: rgba(156, 144, 255, 0.16); }
  body[data-section="stepland"]       { --accent: #52C9AE; --accent-ink: #79DBC4; --accent-soft: rgba(82, 201, 174, 0.16); }
  body[data-section="dungeon-heroes"] { --accent: #F58A6C; --accent-ink: #FBA689; --accent-soft: rgba(245, 138, 108, 0.16); }
  body[data-section="purple-pwny"]    { --accent: #DC96CE; --accent-ink: #E9AFDD; --accent-soft: rgba(220, 150, 206, 0.16); }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--field);
  color: var(--body);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 1.04rem;
  line-height: 1.68;
  overflow-x: hidden;
  transition: background 0.4s ease;
}

.display, h1, h2, h3, .wordmark, .tab-label, .lede {
  font-family: "Iowan Old Style", Georgia, "Noto Serif", "Palatino Linotype", serif;
  font-weight: 400;
}

a { color: var(--accent-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

.shell { max-width: var(--shell); margin: 0 auto; padding: 0 var(--gutter); }

/* -------------------------------------------------------------- 2. field -- */

.field {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(58rem 40rem at 6% -8%, var(--accent-soft), transparent 60%),
    radial-gradient(46rem 38rem at 100% 104%, rgba(99, 116, 90, 0.09), transparent 62%);
  transition: background 0.5s ease;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.042;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) { body::after { opacity: 0.055; } }

/* The wash under the header, back from v2 -- but tinted by the active section
   rather than being one permanent orange. */
.header-wash {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 13rem;
  margin-bottom: -13rem;
  pointer-events: none;
  background: linear-gradient(180deg, var(--accent-soft), transparent 78%);
  transition: background 0.45s ease;
}

.motif {
  position: fixed;
  z-index: -1;
  pointer-events: none;
  display: grid;
  grid-template-columns: repeat(6, 14px);
  grid-auto-rows: 14px;
  gap: 4px;
  opacity: 0.7;
}
.motif i { background: currentColor; }
.motif--tl { top: 26vh; left: -20px; color: var(--accent); }
.motif--br { bottom: 14vh; right: -16px; color: var(--accent); }
@media (prefers-color-scheme: dark) { .motif { opacity: 0.4; } }
@media (max-width: 78rem) { .motif { display: none; } }

/* -------------------------------------------------- 3. masthead and tabs -- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 1.25rem 0 0;
  background: color-mix(in srgb, var(--field) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.masthead-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.4rem;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 0.9rem;
}

.wordmark {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  font-weight: 700;
  color: var(--ink);
}
.wordmark .dot { color: var(--accent); }

.masthead-contact { display: flex; gap: 1.1rem; font-size: 0.88rem; }
.masthead-contact a { color: var(--muted-field); text-decoration: none; }
.masthead-contact a:hover { color: var(--accent-ink); text-decoration: underline; }

.tabs { position: relative; display: flex; gap: 0.2rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

@media (max-width: 60rem) {
  .tabs { mask-image: linear-gradient(90deg, #000 88%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); }
}

/* The two-line tab is back. The kicker is now 11.5px at full opacity in --muted
   (5.4:1) instead of 10px at 0.72 opacity in --slate (2.36:1). */
.tab {
  flex: 0 0 auto;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0.35rem 1rem 0.85rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s ease, transform 0.2s ease;
}

.tab-kicker {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted-field);
  transition: color 0.2s ease;
}

.tab-label {
  display: block;
  font-size: 1.12rem;
  line-height: 1.25;
  color: var(--muted-field);
  transition: color 0.2s ease;
}

.tab:hover .tab-label,
.tab:hover .tab-kicker { color: var(--ink); }
.tab[aria-selected="true"] .tab-label { color: var(--ink); font-weight: 700; }
.tab[aria-selected="true"] .tab-kicker { color: var(--accent-ink); }

.tab-indicator {
  position: absolute;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  transition: transform 0.34s cubic-bezier(0.4, 0.05, 0.2, 1),
              width 0.34s cubic-bezier(0.4, 0.05, 0.2, 1),
              background 0.4s ease;
  will-change: transform, width;
}

/* ------------------------------------------------------ 4. sheet and grid -- */

.view { display: none; }
.view.is-active { display: block; animation: fade 0.3s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: relative;
  margin: clamp(1.6rem, 4vw, 2.6rem) 0 clamp(3rem, 7vw, 5rem);
  padding: clamp(1.6rem, 4vw, 3rem) var(--pad) clamp(2rem, 5vw, 3.4rem);
  background: var(--paper);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sheet::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
  background: var(--accent);
  transition: background 0.4s ease;
}

/* The asymmetric grid. A fixed reading measure, then whatever is left becomes
   the margin column -- so the text never gets wider than it should be, and the
   leftover space carries something instead of sitting empty. */
.doc {
  display: grid;
  grid-template-columns: minmax(0, var(--read)) minmax(14rem, 1fr);
  gap: 0 var(--gap);
  align-items: start;
}

.doc-main, .hero { grid-column: 1; min-width: 0; }
.margin-col { grid-column: 2; min-width: 0; }
/* Sticky only where the reading column guarantees a tall enough row. */
.doc-main + .margin-col { position: sticky; top: 9.5rem; }
.band.full { grid-column: 1 / -1; }

@media (max-width: 66rem) {
  .doc { grid-template-columns: minmax(0, 1fr); }
  .doc-main, .hero, .margin-col, .band.full { grid-column: 1; }
  .doc-main + .margin-col { position: static; }
  .margin-col { margin-bottom: 2rem; }
}

/* ----------------------------------------------------------- 5. overview -- */

.eyebrow {
  margin: 0 0 0.7rem;
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-ink);
}

.lede {
  margin: 0 0 1.1rem;
  font-size: clamp(1.5rem, 2.6vw, 2.15rem);
  line-height: 1.28;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.sub { margin: 0 0 1.6rem; max-width: 40em; }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.7rem 1rem; margin: 0; padding: 0; list-style: none; }
.chips a { font-size: 0.94rem; text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent-ink) 40%, transparent); }
.chips a:hover { border-bottom-color: currentColor; }

.chips .primary {
  padding: 0.55rem 1.1rem;
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  transition: transform 0.16s ease, background 0.16s ease;
}
.chips .primary:hover { transform: translateY(-2px); background: var(--accent-ink); }

/* Facts in the margin column: a dl, not a card. */
.facts { margin: 0.4rem 0 0; padding: 0 0 0 1.15rem; border-left: 2px solid var(--rule); }
.facts > div + div { margin-top: 0.9rem; }
.facts dt { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0.1rem 0 0; font-size: 0.94rem; color: var(--ink); }

/* Bands are separated by rules, not by nested cards. */
.band { margin-top: clamp(2.4rem, 5vw, 3.6rem); padding-top: clamp(1.8rem, 4vw, 2.6rem); border-top: 1px solid var(--rule); }
.band-note { margin: 1.4rem 0 0; max-width: 44em; }

.grid { display: grid; gap: 1.6rem; grid-template-columns: 1fr; }
@media (min-width: 52rem) { .grid { grid-template-columns: repeat(3, 1fr); } }

/* No card chrome: a rule and space do the grouping. */
.ship { display: grid; grid-template-rows: auto auto 1fr; gap: 0.15rem; padding-left: 1.1rem; border-left: 2px solid var(--accent); }
.ship:nth-child(2) { border-left-color: var(--muted); }
.ship:nth-child(3) { border-left-color: var(--rule); }
.ship h3 { margin: 0; font-size: 1.2rem; color: var(--ink); }
.ship .meta { margin: 0 0 0.35rem; min-height: 2.6em; font-size: 0.76rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.ship p:last-child { margin: 0; font-size: 0.95rem; }

.studies { display: grid; gap: 0; }

.study {
  position: relative;
  display: grid;
  gap: 0.2rem;
  padding: 1.5rem 3rem 1.5rem 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
  transition: padding-left 0.22s ease;
}
.studies .study:first-child { border-top: 1px solid var(--rule); }

.study::after {
  content: "→";
  position: absolute;
  right: 0.6rem;
  top: 2.9rem;
  color: var(--accent);
  opacity: 0.5;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.study:hover { padding-left: 0.9rem; }
.study:hover::after { opacity: 1; transform: translateX(4px); }

.study h3 { margin: 0.3rem 0 0.25rem; font-size: 1.4rem; line-height: 1.25; color: var(--ink); }
.study p { margin: 0; max-width: 52em; font-size: 0.97rem; }

.tag {
  justify-self: start;
  padding: 0.16rem 0.6rem;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ----------------------------------------------------------- 6. document -- */

article h1 {
  margin: 0 0 1.3rem;
  font-size: clamp(2rem, 3.4vw, 2.9rem);
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.015em;
  color: var(--ink);
}

article h2 {
  position: relative;
  margin: 3.2rem 0 0.9rem;
  font-size: clamp(1.45rem, 1.1vw + 1.1rem, 1.85rem);
  font-weight: 700;
  line-height: 1.26;
  color: var(--ink);
  scroll-margin-top: 10rem;
}

article h2::before {
  content: "";
  position: absolute;
  left: -1.3rem;
  top: 0.2em;
  bottom: 0.2em;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
}
@media (max-width: 52rem) { article h2::before { display: none; } }

article h3 { margin: 2.1rem 0 0.45rem; font-size: 1.28rem; font-weight: 700; color: var(--ink); }
article h4 { margin: 1.6rem 0 0.35rem; font-size: 0.83rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

article p { margin: 0 0 1rem; }
article ul, article ol { margin: 0 0 1.15rem; padding-left: 1.4rem; }
article li { margin-bottom: 0.45rem; }
article li::marker { color: var(--muted); }
article ol > li::marker { color: var(--accent-ink); font-weight: 700; }
article strong { font-weight: 600; color: inherit; }

article hr { width: 100%; height: 1px; margin: 2.8rem 0; border: 0; background: var(--rule); }

article blockquote {
  margin: 0 0 1.6rem;
  padding: 1.05rem 1.2rem;
  background: var(--sunken);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
article blockquote p:last-child { margin: 0; }

code {
  padding: 0.06em 0.32em;
  background: var(--accent-soft);
  border-radius: 4px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  font-size: 0.87em;
  color: var(--ink);
}

/* -------------------------------------------------------- 7. pinned index -- */

.toc { font-size: 0.92rem; }
.toc-title { margin: 0 0 0.7rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.toc ol { margin: 0; padding: 0; list-style: none; counter-reset: toc; }
.toc li { counter-increment: toc; }

.toc a {
  display: block;
  padding: 0.32rem 0 0.32rem 0.9rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
  text-decoration: none;
  line-height: 1.35;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.toc a::before { content: counter(toc) ". "; color: var(--muted); opacity: 0.75; }
.toc a:hover { color: var(--ink); border-left-color: var(--muted); }
.toc a.is-current { color: var(--accent-ink); border-left-color: var(--accent); font-weight: 600; }
.toc a.is-current::before { color: var(--accent); }

/* ------------------------------------------------- 8. tables and figures -- */

.scroll {
  max-width: 100%;
  overflow-x: auto;
  margin: 0 0 1.6rem;
  background: var(--sunken);
  border: 1px solid var(--edge);
  border-radius: 8px;
}
@media (max-width: 44rem) {
  .scroll { mask-image: linear-gradient(90deg, #000 92%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); }
}

table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 0.91rem; }
th, td { padding: 0.55rem 0.8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
th { background: color-mix(in srgb, var(--accent-soft) 60%, var(--paper)); color: var(--ink); font-weight: 700; }
th:first-child, td:first-child { width: 34%; }
table.keyvalue td:first-child { font-weight: 700; color: var(--ink); }
tbody tr:last-child td { border-bottom: 0; }

.shots { display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); align-items: start; margin: 0 0 1.4rem; }
.shot { margin: 0; }
/* A lone portrait screenshot should not letterbox across the whole column. */
.shots .shot:only-child { max-width: 21rem; margin-inline: auto; }
.shot img {
  display: block;
  width: 100%;
  max-height: 64vh;
  object-fit: contain;
  object-position: top;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--sunken);
}
.shot figcaption { margin-top: 0.55rem; font-size: 0.86rem; line-height: 1.5; color: var(--body); }
article img { max-width: 100%; height: auto; }

/* -------------------------------------------------------------- 9. chrome -- */

footer { padding: 2.2rem 0 3rem; border-top: 1px solid var(--rule); font-size: 0.92rem; }
footer p { margin: 0 0 0.4rem; max-width: 44em; }
footer p:last-child { margin: 0; }
footer strong { color: var(--ink); }

* { scrollbar-width: thin; scrollbar-color: var(--muted) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--muted); border: 3px solid transparent; background-clip: padding-box; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }

::selection { background: var(--accent); color: #12161C; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent-soft); border-radius: 3px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@media (max-width: 34rem) {
  th, td { padding: 0.45rem 0.55rem; }
  table { font-size: 0.86rem; }
}
