/* warm-light — Charter / serif / paper / 70ch measure
   Ported from demo/ui-gallery/reader-warm/style.css.
   Inspired by Craig Mod, Robin Sloan, Robin Rendle's reader-web movement. */

:root {
  --paper:   #fbf7ee;
  --ink:     #222222;
  --dim:     #5a544a;
  --rule:    #e9e0c8;
  --accent:  #7a4f17;
  --danger:  #a14f3a;
  --ok:      #3e6b3a;
  --pending: #b7892b;
  --info:    #4a6e9c;
  --neutral: #5a544a;
  --card-bg: #f5efdf;
  --code-bg: #efe7d2;
}

/* Honour the system preference only when no explicit mode has been picked.
   The chrome emits `<html data-mode-source="auto">` exactly when the mode
   cookie is absent; once the operator picks Light or Dark, the attribute is
   gone and the explicit choice cannot be overridden by the system pref. */
@media (prefers-color-scheme: dark) {
  html[data-mode-source="auto"] {
    --paper:   #1c1a17;
    --ink:     #ece4d2;
    --dim:     #8a8273;
    --rule:    #2e2a25;
    --accent:  #d6a772;
    --danger:  #d8806a;
    --ok:      #8db184;
    --pending: #d6b86b;
    --info:    #7da9d6;
    --neutral: #8a8273;
    --card-bg: #232017;
    --code-bg: #28241d;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Charter", "Iowan Old Style", "Apple Garamond", "Baskerville", "Palatino", Georgia, serif;
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { max-width: 70ch; margin: 0 auto; padding: 0 1.25rem; }
/* Round-4: underlines are off everywhere by default. Browser-default
   `text-decoration: underline` was still leaking through on links outside the
   `main a:not(...)` rule (e.g., footer hrefs); operator wants colour-only
   affordances site-wide. The accent-colour rule below opts content-area
   links into `var(--accent)`; hover restores the underline as the
   interaction signal. */
a, a:visited { text-decoration: none; }
/* Content-area links use accent colour only. Selector excludes header/footer
   chrome links, button-styled anchors, card-link wrappers, and chips
   (which carry their own colour rules). Explicit `:visited` keeps visited
   links in accent rather than falling back to the browser's default
   purple. */
main a:not(.btn):not(.card-link):not(.brand):not(.chip),
main a:not(.btn):not(.card-link):not(.brand):not(.chip):visited {
  color: var(--accent);
}
/* No hover underline — operator preference. Colour stays var(--accent). */

/* HEADER */
.site-header {
  border-bottom: 1px solid var(--rule);
  padding: 1rem 0;
  margin-bottom: 2rem;
}
.header-wrap { display: flex; align-items: baseline; gap: 1.5rem; flex-wrap: wrap; }
.brand {
  font-family: "Charter", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 1.4rem;
  color: var(--ink);
  text-decoration: none;
}
.brand-dot { color: var(--accent); }
nav { display: flex; gap: 1.25rem; flex: 1; flex-wrap: wrap; }
nav a { color: var(--ink); text-decoration: none; }
nav a:hover, nav a.active { color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 1rem; }
.link-btn {
  background: none; border: none; color: var(--accent); font: inherit;
  cursor: pointer;
}

/* HEADINGS */
h1 { font-size: 2.6rem; line-height: 1.1; margin: .25em 0 .25em; font-weight: 500; }
h2 { font-size: 1.7rem; line-height: 1.2; margin: 1.5em 0 .5em; font-weight: 500; }
h3 { font-size: 1.25rem; font-style: italic; margin: 1em 0 .25em; font-weight: 400; }
.subhead { font-size: 1.2rem; color: var(--dim); font-style: italic; margin-top: 0; }
.kicker { font-size: .9rem; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; margin: 0; }
.kicker a { color: var(--accent); }

/* PAGE HEAD */
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
/* Warm-specific: the page-head CTA (e.g. "Add feed") renders as a plain
   accent-coloured link rather than the heavy solid-black `btn-primary` to
   match the theme's reader aesthetic. No underline / border on the CTA per
   the operator's no-underlines preference. */
.page-head .btn-primary {
  background: transparent;
  color: var(--accent);
  border: none;
  padding: .15rem 0;
  border-radius: 0;
  font-size: 1rem;
}

/* RULES */
.rule { border: none; border-top: 1px solid var(--rule); margin: 2.5rem auto; max-width: 12rem; }

/* TWO-COL */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

/* CARD LIST */
.card-list { list-style: none; padding: 0; margin: 0; }
.card {
  border-bottom: 1px solid var(--rule);
  padding: 1rem 0;
}
.card:last-child { border-bottom: none; }
.card-row { display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; }
/* Card-meta sits below the title and carries small-caps secondary data
   (counts, dates, status chips). Tighten the flex layout so the cells
   stay on one line until truly necessary, and right-align the trailing
   numeric/chip cells against the row's left-aligned leading cell. */
.card-row.card-meta {
  font-size: .8rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  gap: .5rem .75rem;
  align-items: center;
}
.card-row.card-meta > :first-child { margin-right: auto; }
.card-row.card-meta > * { white-space: nowrap; }
.card-meta { font-size: .85rem; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.card-title { margin: .25rem 0; font-size: 1.4rem; font-weight: 500; }
.card-link { color: var(--ink); text-decoration: none; display: block; }
.card-link .card-title { display: inline; }
.card-summary { margin: .25rem 0; color: var(--ink); }
.card-action a { color: var(--accent); font-style: italic; text-decoration: none; }
/* no hover underline */

/* FORMS */
.form-field { display: block; margin-bottom: 1rem; }
.form-label { display: block; font-style: italic; color: var(--dim); font-size: .95rem; }
.req { color: var(--danger); }
.form-field input, .form-field select, .form-field textarea {
  display: block; width: 100%;
  font-family: inherit; font-size: 1rem;
  margin-top: .25rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  padding: .35rem 0;
  color: var(--ink);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-bottom-color: var(--accent); }
.form-caption { display: block; color: var(--dim); font-size: .8rem; margin-top: .25rem; }
.form-error { display: block; color: var(--danger); font-size: .8rem; margin-top: .25rem; }

/* BUTTONS */
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; justify-content: center; }
/* Single-button row sibling to FormField stack. Used on `/account` and other
   short forms where a full FormActions (Cancel + Save) is overkill. */
.form-row { margin-top: 1.25rem; }
/* Account page stacks two forms (preferences, sign-out). Both forms carry
   `class="account-form"` (the previous polish targeted `.prefs-form` /
   `.logout-form` which never matched — the underlying class names had been
   renamed). Adjacent-sibling selector + a non-trivial gap (2rem) so Save
   and Sign-out can't visually merge on touch. */
.account-form + .account-form { margin-top: 2rem; }
/* Bare-glyph icon button. No border, no background — just the glyph itself.
   Round-4: glyph rendered at ~1.5rem so it reads as an icon rather than as
   inline text (the previous `font: inherit` made it look like a typo on
   mobile). Padding pushes the box to ≥44×44px per the Warm style guide
   tap-target rule even though the glyph itself is only ~24px tall. Used on
   feed-detail for `↻` (poll-now) and `⛭` (settings) and any other
   icon-shaped action. Hover transitions to accent so the affordance is
   visible. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: .5rem .6rem;
  min-width: 44px;
  min-height: 44px;
  color: var(--dim);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}
.icon-btn:hover { color: var(--accent); }
/* Feed-detail header. Round-4 layout: title row (`.feed-title` +
   `.feed-actions`) on grid row 1; settings panel as a full-width row 2
   that only renders when the `<details>` widget inside `.feed-actions`
   is open. The panel is a peer of the title row (NOT nested inside
   `.feed-actions`), so its width is the full grid width regardless of
   how cramped the action slot is on mobile. Visibility is driven by
   `:has(details[open])` — no JS, no duplicate glyphs. */
.feed-header {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: .5rem;
  row-gap: .5rem;
  margin-bottom: 1rem;
}
.feed-header > .feed-title { grid-column: 1; grid-row: 1; margin: 0; min-width: 0; }
.feed-header > .feed-actions { grid-column: 2; grid-row: 1; }
.feed-header > .feed-settings { grid-column: 1 / -1; grid-row: 2; display: none; }
.feed-header:has(details.settings-toggle[open]) > .feed-settings { display: block; }
.feed-actions { display: inline-flex; gap: .25rem; align-items: center; }
.feed-actions form.inline { display: inline; margin: 0; }
/* `.settings-toggle` is the `<details>` wrapper; its only child is the
   gear-glyph `<summary>`. Hide the default disclosure marker so only
   the glyph shows. */
.settings-toggle { display: inline; }
.settings-toggle > summary {
  list-style: none;
  cursor: pointer;
}
.settings-toggle > summary::-webkit-details-marker { display: none; }
.settings-toggle[open] > summary { color: var(--accent); }
.feed-settings { padding: .5rem .75rem; background: var(--card-bg); border: 1px solid var(--rule); border-radius: 2px; }
.settings-edit { margin-top: .75rem; font-size: .9rem; }
.btn {
  font-family: inherit; font-size: 1rem;
  padding: .5rem 1rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  border-radius: 2px;
  text-decoration: none;
  display: inline-block;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-secondary { background: transparent; }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.inline-form { display: inline; }

/* CHIPS — tight pill, dim hairline border, font-size matches surroundings.
   The previous shape used `currentColor` for the border which painted the
   whole chip in the chip-tone colour and made it visually loud; rounding
   that down to `var(--rule)` keeps the colour cue on the text only. */
.chip {
  display: inline-block; font-size: inherit; font-style: italic;
  padding: .05rem .35rem; border-radius: 999px; margin-right: .25rem;
  border: 1px solid var(--rule);
  vertical-align: baseline;
}
.chip-ok { color: var(--ok); }
.chip-fail { color: var(--danger); }
.chip-pending { color: var(--pending); }
.chip-info { color: var(--info); }
.chip-neutral { color: var(--neutral); }

/* SETTINGS */
.settings { margin: 0; }
.settings dt { font-style: italic; color: var(--dim); margin-top: .75rem; }
.settings dd { margin-left: 0; padding-left: 0; }

/* FEED SUMMARY — vertical rhythm rule for paragraphs inside the feed-detail
   summary card. The url / cadence / poll-status lines previously had no
   shared margin rule, so the gaps depended on whichever paragraph carried
   the larger natural margin. This collapses them to a consistent rhythm
   matching the theme (Warm: ~0.6rem). Same rule lives in tufte-light /
   tufte-dark with the smaller Tufte rhythm value. */
.feed-summary > * + * { margin-top: .6rem; }

/* TABLE */
.data { width: 100%; border-collapse: collapse; }
.data th, .data td { text-align: left; padding: .5rem .25rem; border-bottom: 1px solid var(--rule); }
.data th { font-weight: 500; font-style: italic; color: var(--dim); font-size: .9rem; }

/* DIALOG */
.dialog {
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 2px;
}
.dialog-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }

/* CODE */
.code, code, .mono {
  font-family: "JetBrains Mono", "iA Writer Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .9rem;
}
.code {
  background: var(--code-bg);
  padding: .85rem 1rem;
  border-radius: 2px;
  overflow-x: auto;
  font-size: .85rem;
}
code { background: var(--code-bg); padding: 1px 5px; border-radius: 2px; }

/* EMPTY */
.empty { padding: 1.25rem; text-align: center; border: 1px dashed var(--rule); border-radius: 2px; }
.dim, .muted { color: var(--dim); }
.small { font-size: .9rem; }

/* ALERTS */
.alert { padding: .75rem 1rem; border-radius: 2px; margin: 1rem 0; border: 1px solid currentColor; }
.alert-error { color: var(--danger); }
.alert-warn { color: var(--pending); }
.alert-info { color: var(--info); }

/* STATUS FILTER — round-4 swap from chip row to `<select>`. Dim italic
   label adjacent to a hairline-underline themed select that matches the
   `.form-field` input shape. The select itself shrinks to the widest
   option label rather than spanning the row, so the row stays tight on
   mobile. */
.status-filter {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}
.status-filter label {
  font-style: italic;
  color: var(--dim);
  font-size: .95rem;
}
.status-filter select {
  font-family: inherit;
  font-size: 1rem;
  background: transparent;
  color: var(--ink);
  border: none;
  border-bottom: 1px solid var(--rule);
  padding: .25rem 1.5rem .25rem 0;
  cursor: pointer;
}
.status-filter select:focus { outline: none; border-bottom-color: var(--accent); }

/* METRICS — round-3 polish. Three tiles, equal-width grid, stacked
   label-on-top + big-number-below. Padding is tight enough to fit three
   tiles on a 360px viewport (360/3 ≈ 120px per tile, ≤6px padding). */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin: 1rem 0;
}
.metric {
  padding: .35rem .25rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .15rem;
  min-width: 0;
  text-align: center;
}
.metric-label {
  font-size: .7rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.metric-value {
  font-size: 1.6rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.metric-ok .metric-value { color: var(--ok); }
.metric-fail .metric-value { color: var(--danger); }
.metric-pending .metric-value { color: var(--pending); }
.metric-info .metric-value { color: var(--info); }

/* LOGIN */
.login-card {
  max-width: 22rem; margin: 4rem auto;
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--card-bg);
}
.login-card h1 { font-size: 1.6rem; margin-top: 0; }
.login-card input {
  display: block; width: 100%;
  font-family: inherit; font-size: 1rem;
  margin: .25rem 0 1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  padding: .35rem 0;
  color: var(--ink);
}

/* SWATCHES */
.swatches { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: .5rem; }
.sw {
  padding: 1rem .75rem;
  border-radius: 2px;
  font-size: .85rem;
  display: flex; flex-direction: column; gap: .35rem;
  border: 1px solid var(--rule);
}
.sw span:last-child { font-family: "JetBrains Mono", monospace; font-size: .75rem; opacity: .8; }

/* TYPE SAMPLE */
.type-sample > * { margin: .5em 0; }

/* FOOTER */
.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--rule);
  color: var(--dim);
  font-style: italic;
  font-size: .9rem;
  text-align: center;
}
.site-footer a { color: var(--accent); }
