/* ===========================================================================
   tweaks.css — palette / voice / rhythm variations + tweak panel UI
   Only loaded on index.html.
   Newsreader is loaded via <link> in index.html, not @import, so the
   stylesheet doesn't block parse on a webfont fetch.
   =========================================================================== */

/* ----------- PALETTE: Paper (warm cream + rust) ----------- */
body[data-palette="paper"] {
  --bg: #F4ECDE;
  --bg-sunk: #E9DFCB;
  --fg: #1F1611;
  --fg-soft: #2C2018;
  --muted: #76685A;
  --muted-2: #A09583;
  --line: #DFD2BB;
  --line-strong: #C9BCA1;
  --accent: #983B1B;
}
body[data-palette="paper"] header.site {
  background: rgba(244, 236, 222, 0.82);
}

/* ----------- PALETTE: Graphite (dark) ----------- */
body[data-palette="graphite"] {
  --bg: #100F0D;
  --bg-sunk: #1B1916;
  --fg: #F1EDE4;
  --fg-soft: #DDD7C9;
  --muted: #9C9587;
  --muted-2: #6B6458;
  --line: #25221E;
  --line-strong: #3A352E;
  --accent: #B7C7FF;
}
body[data-palette="graphite"] header.site {
  background: rgba(16, 15, 13, 0.85);
}
body[data-palette="graphite"] ::selection { background: var(--accent); color: var(--bg); }

/* ----------- PALETTE: Mono (no accent) ----------- */
body[data-palette="mono"] {
  --accent: var(--fg);
}
body[data-palette="mono"] .hero .eyebrow .dot { background: var(--fg); }
body[data-palette="mono"] a.email,
body[data-palette="mono"] .footer-big a {
  color: var(--fg);
}
body[data-palette="mono"] .work-meta .read-more:hover {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

/* ===========================================================================
   VOICE
   =========================================================================== */

/* ----------- VOICE: Literary (serif headlines) ----------- */
body[data-voice="literary"] .hero h1,
body[data-voice="literary"] .prose-section h2,
body[data-voice="literary"] .footer-big,
body[data-voice="literary"] .work-meta h3 {
  font-family: 'Newsreader', "Source Serif 4", Georgia, serif;
  font-weight: 400;
  letter-spacing: -0.012em;
  font-feature-settings: "ss01";
}
body[data-voice="literary"] .hero h1 {
  font-size: clamp(46px, 6vw, 88px);
  line-height: 1.0;
  font-weight: 400;
}
body[data-voice="literary"] .hero h1 em,
body[data-voice="literary"] .prose-section h2 em {
  font-style: italic;
  font-weight: 400;
}
body[data-voice="literary"] .work-meta h3 {
  font-size: 32px;
  letter-spacing: -0.01em;
}
body[data-voice="literary"] .footer-big {
  font-size: clamp(36px, 4.4vw, 60px);
  letter-spacing: -0.015em;
}

/* ----------- VOICE: Technical (mono headlines) ----------- */
body[data-voice="technical"] .hero h1 {
  font-family: 'Geist Mono', ui-monospace, SFMono-Regular, monospace;
  font-weight: 400;
  font-size: clamp(26px, 3.4vw, 46px);
  letter-spacing: -0.008em;
  line-height: 1.18;
  max-width: 30ch;
}
body[data-voice="technical"] .hero h1 em {
  font-style: normal;
  background: var(--fg);
  color: var(--bg);
  padding: 0 8px;
  margin: 0 -2px;
  display: inline-block;
  border-radius: 1px;
}
body[data-voice="technical"] .prose-section h2,
body[data-voice="technical"] .footer-big {
  font-family: 'Geist Mono', ui-monospace, monospace !important;
  font-size: clamp(22px, 2.6vw, 30px) !important;
  letter-spacing: -0.006em;
  line-height: 1.3 !important;
  font-weight: 400;
}
body[data-voice="technical"] .work-meta h3 {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 21px;
  letter-spacing: -0.004em;
  line-height: 1.35;
  font-weight: 400;
}
body[data-voice="technical"] .hero .lede {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 15px;
  line-height: 1.7;
  letter-spacing: 0.005em;
  color: var(--muted);
}

/* ===========================================================================
   RHYTHM (selected-work layout)
   =========================================================================== */

/* ----------- RHYTHM: Stacked (full-bleed thumbs) ----------- */
body[data-rhythm="stacked"] .work-row {
  grid-template-columns: 1fr;
  gap: 36px;
  padding: 80px 0;
}
body[data-rhythm="stacked"] .work-row.reverse .work-thumb { order: 0; }
body[data-rhythm="stacked"] .work-row.reverse .work-meta { order: 0; }
body[data-rhythm="stacked"] .work-thumb {
  aspect-ratio: 21 / 9;
}
body[data-rhythm="stacked"] .work-meta {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  grid-template-areas:
    "idx    idx"
    "title  stack"
    "desc   read";
  column-gap: 64px;
  row-gap: 14px;
  align-items: start;
}
body[data-rhythm="stacked"] .work-meta .row-index { grid-area: idx; margin-bottom: 0; }
body[data-rhythm="stacked"] .work-meta h3 { grid-area: title; margin-bottom: 0; max-width: none; }
body[data-rhythm="stacked"] .work-meta .one-line { grid-area: desc; max-width: 58ch; margin-bottom: 0; }
body[data-rhythm="stacked"] .work-meta .stack { grid-area: stack; align-self: start; margin-bottom: 0; }
body[data-rhythm="stacked"] .work-meta .read-more {
  grid-area: read;
  justify-self: start;
  align-self: end;
  margin-top: 8px;
}

/* ----------- RHYTHM: Magazine (oversized serif index numerals) ----------- */
body[data-rhythm="magazine"] section.work .work-list { counter-reset: work; }
body[data-rhythm="magazine"] .work-row {
  counter-increment: work;
  grid-template-columns: minmax(180px, 220px) 1fr 1.4fr;
  gap: 56px;
  align-items: start;
  padding: 88px 0;
}
body[data-rhythm="magazine"] .work-row::before {
  content: counter(work, decimal-leading-zero);
  font-family: 'Newsreader', "Source Serif 4", Georgia, serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(120px, 14vw, 200px);
  line-height: 0.82;
  color: var(--fg);
  opacity: 0.16;
  letter-spacing: -0.04em;
  align-self: start;
  margin-top: -16px;
}
body[data-rhythm="magazine"] .work-row.reverse .work-thumb { order: 0; }
body[data-rhythm="magazine"] .work-row.reverse .work-meta { order: 0; }
body[data-rhythm="magazine"] .work-meta .row-index { display: none; }
body[data-rhythm="magazine"] .work-thumb {
  aspect-ratio: 4 / 5;
}
body[data-rhythm="magazine"] .work-meta h3 {
  font-size: clamp(28px, 2.6vw, 34px);
}

/* combined: literary + magazine = drop the magazine into a slightly different rhythm */
body[data-voice="literary"][data-rhythm="magazine"] .work-row::before {
  opacity: 0.22;
}

/* ===========================================================================
   TWEAKS PANEL UI
   =========================================================================== */

.tweaks-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 280px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow:
    0 24px 56px -16px rgba(0, 0, 0, 0.18),
    0 4px 12px rgba(0, 0, 0, 0.06);
  z-index: 100;
  font-family: 'Geist', sans-serif;
  display: none;
  user-select: none;
  overflow: hidden;
}
.tweaks-panel.on { display: block; }

body[data-palette="graphite"] .tweaks-panel {
  box-shadow:
    0 24px 56px -16px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(0, 0, 0, 0.2);
}

.tweaks-panel .tw-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunk);
}
.tweaks-panel .tw-head .label {
  color: var(--fg);
  font-size: 10.5px;
}
.tweaks-panel .tw-close {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  width: 22px;
  height: 22px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Geist Mono', monospace;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.tweaks-panel .tw-close:hover {
  background: var(--bg);
  color: var(--fg);
  border-color: var(--line-strong);
}

.tweaks-panel .group {
  padding: 16px 16px 16px;
  border-bottom: 1px solid var(--line);
}
.tweaks-panel .group:last-child { border-bottom: none; }
.tweaks-panel .group > .label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
}

.tweaks-panel .seg {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  overflow: hidden;
}
.tweaks-panel .seg button {
  background: var(--bg);
  border: none;
  border-right: 1px solid var(--line-strong);
  padding: 8px 4px;
  font: inherit;
  font-size: 10.5px;
  font-family: 'Geist Mono', ui-monospace, monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.tweaks-panel .seg button:last-child { border-right: none; }
.tweaks-panel .seg button:hover { background: var(--bg-sunk); }
.tweaks-panel .seg button.on {
  background: var(--fg);
  color: var(--bg);
}

.tweaks-panel .swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.tweaks-panel .swatches button {
  aspect-ratio: 1 / 1;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  display: flex;
}
.tweaks-panel .swatches button:hover { border-color: var(--fg); }
.tweaks-panel .swatches button.on {
  border-color: var(--fg);
  box-shadow: inset 0 0 0 2px var(--bg), inset 0 0 0 3px var(--fg);
}
.tweaks-panel .swatches .h {
  display: block;
  flex: 1;
  height: 100%;
}

.tweaks-panel .swatch-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.tweaks-panel .swatch-row span { text-align: center; }

/* Tiny hint label at the bottom edge of the panel */
.tweaks-panel .tw-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-sunk);
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
  text-align: center;
}

@media (max-width: 880px) {
  .tweaks-panel {
    right: 16px;
    left: 16px;
    bottom: 16px;
    width: auto;
  }
}
