/* strwb. — shared styles for every page.
   Tokens first, then the fixed chrome (home button + theme switch), then the
   handful of components the pages share. Dark is the default; strwb.js flips
   [data-theme] on <html> before the first paint. */

:root {
  --accent: #ff4747;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --shell-x: clamp(20px, 5vw, 42px);
  --chrome-y: clamp(18px, 4vw, 32px);
  --radius: 14px;
}

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #100e0e;
  --fg: #e9e3df;
  --fg-strong: #f5eeee;
  --muted: #968984;
  --faint: #6b605e;
  --line: #2b1616;
  --line-soft: #1d1414;
  --fade-1: #5d1d1d;
  --fade-2: #230e0e;
  --chrome-bg: rgba(20, 14, 14, .55);
  --chrome-line: rgba(233, 227, 223, .16);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fbf8f7;
  --surface: #ffffff;
  --fg: #1a1514;
  --fg-strong: #0d0a09;
  --muted: #6d6260;
  --faint: #8b7e7b;
  --line: #e8dcd9;
  --line-soft: #f1e9e7;
  --fade-1: #ff9a9a;
  --fade-2: #ffdedb;
  --chrome-bg: rgba(255, 255, 255, .7);
  --chrome-line: rgba(26, 21, 20, .14);
}

* { box-sizing: border-box; }

html { scrollbar-color: var(--accent) transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s, color .25s;
}

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

a { color: inherit; }

/* no grey/blue flash when tapping on phones; focus-visible styles still show */
html { -webkit-tap-highlight-color: transparent; }

/* --- Fixed chrome ------------------------------------------------------- */

.home,
.settings-button {
  position: fixed;
  top: var(--chrome-y);
  z-index: 60;
  border: 1px solid var(--chrome-line);
  border-radius: 999px;
  background: var(--chrome-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.home {
  left: var(--shell-x);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px 0 11px;
  color: var(--fg);
  font-size: .78rem;
  letter-spacing: -.01em;
  text-decoration: none;
  transition: border-color .2s, color .2s;
}

.home svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .2s, stroke .2s;
}

.home:hover { color: var(--fg-strong); border-color: var(--accent); }
.home:hover svg { transform: translateX(-3px); stroke: var(--accent); }
.home:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.settings-button {
  right: var(--shell-x);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--fg);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color .2s, color .2s, transform .3s cubic-bezier(.25, 1, .5, 1);
}

.settings-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.settings-button:hover,
.settings-button[aria-expanded="true"] { border-color: var(--accent); transform: rotate(30deg); }
.settings-button:active { transform: rotate(30deg) scale(.94); }
.settings-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* --- Settings drawer ----------------------------------------------------
   Slides in from the right; the page behind blurs. The backdrop fades with
   opacity (not by animating the blur) so it all stays on the GPU. */

dialog.settings {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(21rem, 86vw);
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font);
  box-shadow: -30px 0 70px -40px rgba(0, 0, 0, .8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translate3d(100%, 0, 0);
  transition: transform .24s cubic-bezier(.25, 1, .5, 1);
}
dialog.settings:not([open]) { display: none; }
dialog.settings:focus { outline: none; }
dialog.settings.in { transform: translate3d(0, 0, 0); transition-duration: .3s; }
dialog.settings.dragging { transition: none; }
@starting-style {
  dialog.settings[open] { transform: translate3d(100%, 0, 0); }
  dialog.settings[open]::backdrop { opacity: 0; }
}

dialog.settings::backdrop {
  background: rgba(0, 0, 0, .45);
  -webkit-backdrop-filter: blur(10px) saturate(.85);
  backdrop-filter: blur(10px) saturate(.85);
  opacity: 0;
  transition: opacity .3s cubic-bezier(.25, 1, .5, 1);
}
:root[data-theme="light"] dialog.settings::backdrop { background: rgba(26, 21, 20, .18); }
dialog.settings.in::backdrop { opacity: 1; }

html.settings-open, html.settings-open body { overflow: hidden; }

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex: none;
  padding: 1.1rem 1.1rem 1rem;
  border-bottom: 1px solid var(--line-soft);
}
.settings-head h2 {
  margin: 0;
  color: var(--fg-strong);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.settings-head h2::after { content: "."; color: var(--accent); }

.settings-close {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin: -.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.settings-close svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.settings-close:hover { background: var(--line-soft); color: var(--fg); }
.settings-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.settings-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom, 0px));
}
.settings-group + .settings-group { margin-top: 1.15rem; }
.settings-label {
  display: block;
  margin: 0 0 .45rem;
  color: var(--faint);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
}

/* segmented control: every option in view, the chosen one lit */
.settings-seg {
  display: flex;
  padding: 2px;
  border-radius: 10px;
  background: var(--line-soft);
}
.settings-seg button {
  flex: 1;
  min-width: 0;
  padding: .45rem .2rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: 400 .82rem/1.2 var(--font);
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}
.settings-seg button:hover { color: var(--fg); }
.settings-seg button:active { transform: scale(.97); }
.settings-seg button[aria-checked="true"] { background: var(--bg); color: var(--fg-strong); font-weight: 600; box-shadow: inset 0 0 0 1px var(--accent); }
.settings-seg button:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.settings-seg [data-font-sample="inter"] { font-family: 'Inter', sans-serif; }
.settings-seg [data-font-sample="domine"] { font-family: 'Domine', serif; }
.settings-seg [data-font-sample="glyphic"] { font-family: 'Faculty Glyphic', sans-serif; }
@media (pointer: coarse) { .settings-seg button { padding: .68rem .2rem; } }

.settings-reset {
  display: block;
  width: 100%;
  margin: 1.5rem 0 0;
  padding: .55rem .6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: 400 .8rem var(--font);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.settings-reset:hover { color: var(--fg); border-color: var(--accent); }
.settings-reset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.settings-note {
  margin: .9rem 0 0;
  padding-top: .8rem;
  border-top: 1px solid var(--line-soft);
  color: var(--faint);
  font-size: .72rem;
  line-height: 1.45;
}

/* --- Preferences ----------------------------------------------------------
   Nothing on <html> means the defaults; strwb.js only sets what was changed. */

:root[data-font="domine"] { --font: 'Domine', Georgia, serif; }
:root[data-font="glyphic"] { --font: 'Faculty Glyphic', system-ui, sans-serif; }
:root[data-size="small"] { font-size: 93.75%; }
:root[data-size="large"] { font-size: 112.5%; }
:root[data-motion="reduced"] *,
:root[data-motion="reduced"] *::before,
:root[data-motion="reduced"] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}

/* --- Page shell --------------------------------------------------------- */

.shell {
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  padding: clamp(92px, 13vh, 140px) var(--shell-x) clamp(72px, 12vh, 120px);
}

/* single-purpose pages: one left-aligned column, centred in the viewport */
.shell.stage {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 600px;
}


/* --- Type --------------------------------------------------------------- */

.title {
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 4rem);
  font-weight: 700;
  line-height: .98;
  letter-spacing: -.045em;
  color: var(--fg-strong);
}

.title .dot { color: var(--accent); }

.lede {
  margin: 20px 0 0;
  max-width: 54ch;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.65;
}

.note { color: var(--faint); font-size: .72rem; line-height: 1.6; }

/* Intro copy: one idea per line on wide screens (the <br> between sentences),
   and on phones, where that break would leave a stub, lines of even length. */
.lede, .note, .hint, .detail, main p { text-wrap: balance; }
@media (max-width: 600px) {
  .lede br, .detail br { display: none; }
}

/* --- Controls ----------------------------------------------------------- */

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn {
  height: 46px;
  padding: 0 22px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: 500 .88rem var(--font);
  letter-spacing: -.01em;
  cursor: pointer;
  transition: filter .2s, transform .1s;
}

.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--fg);
}

.btn.ghost:hover { border-color: var(--accent); color: var(--fg-strong); filter: none; }

.btn:focus-visible,
.field:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.field {
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--fg);
  font: 400 .95rem var(--font);
  outline: none;
  transition: border-color .2s;
}

.field:focus { border-color: var(--accent); }

select.field {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 38px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* --- Small bits --------------------------------------------------------- */

.corner {
  position: fixed;
  right: var(--shell-x);
  bottom: clamp(22px, 4vw, 34px);
  color: var(--faint);
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.corner b { color: var(--muted); font-weight: 500; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(20px, 4vw, 28px);
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .corner { left: var(--shell-x); right: auto; }
}

@media (prefers-reduced-motion: reduce) {
  body, .home svg, .settings-button, dialog.settings, dialog.settings::backdrop, .settings-seg button { transition: none; }
}
