/* Scalearm News — the newsstand: paper surfaces, navy ink, each paper's colour as a thin edge. */

@import url('/tokens.css');

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-top: calc(var(--bar-h) + env(safe-area-inset-top));
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
body.no-tabs { padding-bottom: env(safe-area-inset-bottom); }
[hidden] { display: none !important; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 4px; }

/* ---------- Top bar ---------- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0 16px;
  display: flex; align-items: center; gap: 4px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.bar.has-back { padding-left: 4px; }
.wordmark {
  font: 700 20px/1 var(--head);
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.bar-title { flex: 1; margin: 0; font: 500 16px/1.2 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar > .wordmark { flex: 1; }
.bar-actions { display: flex; align-items: center; }
.icon-btn {
  width: 40px; height: 40px; border: 0; background: none; border-radius: 8px;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.icon-btn:hover { color: var(--ink); }
.icon-btn:active { background: var(--press); }
.icon-btn[aria-pressed="true"] { color: var(--ink); }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }
.icon-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.offline { font-size: 12px; color: var(--ink-3); padding: 0 8px; }

.search-form { flex: 1; }
.search-form input {
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); font-size: 16px;
}
.search-form input:focus { outline: none; border-color: var(--ink-3); }

/* ---------- Pull to refresh ---------- */
.pull {
  position: fixed; left: 0; right: 0; z-index: 10;
  top: calc(var(--bar-h) + env(safe-area-inset-top));
  height: 0; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
  font-size: 12px; color: var(--ink-3);
}
.pull span { padding-bottom: 12px; }

/* ---------- Bottom tabs ---------- */
.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  text-decoration: none; color: var(--ink-3); font-size: 11px; font-weight: 500;
  transition: color 120ms var(--ease);
}
.tabs a[aria-current="page"] { color: var(--ink); }

/* ---------- Page ---------- */
main { max-width: 680px; margin: 0 auto; }
.view { padding: 0 16px 32px; }
.status, .intro, .empty, .fineprint { color: var(--ink-2); font-size: 14px; }
.status { margin: 12px 0 0; }
.status:empty { display: none; }
.empty { margin: 32px 0; }
.intro { margin: 16px 0 8px; }
.fineprint { color: var(--ink-3); font-size: 13px; margin: 20px 0 8px; }

.dateline { margin: 16px 0 0; font-size: 13px; color: var(--ink-3); }

/* Sections: text tabs with an ink underline */
.sections {
  display: flex; gap: 20px; overflow-x: auto; scrollbar-width: none;
  margin: 8px -16px 0; padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.sections::-webkit-scrollbar { display: none; }
.sections a {
  flex: none; padding: 12px 0 10px; font-size: 14px; font-weight: 500; color: var(--ink-3);
  text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 120ms var(--ease), border-color 120ms var(--ease);
}
.sections a[aria-current="true"] { color: var(--ink); border-color: var(--accent); }

/* Paper label with its colour edge (the signature) */
.paper { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.paper::before { content: ''; width: 3px; height: 12px; border-radius: 1px; background: var(--paper, var(--ink-3)); }
@media (prefers-color-scheme: dark) { .paper::before { filter: brightness(1.35) saturate(0.9); } }
.meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.meta .ext { display: inline-flex; align-items: center; gap: 4px; }
.meta .ext svg { width: 13px; height: 13px; }

/* Lead story: the front page moment */
.lead { display: block; padding: 20px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.lead .lead-img {
  display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover;
  border-radius: 8px; background: var(--line); margin-bottom: 16px;
}
.lead h2 {
  margin: 8px 0 0; font: 700 26px/1.14 var(--head);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.lead p.dek { margin: 8px 0 0; font: 16px/1.5 var(--reading); color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Story rows */
.stories { list-style: none; margin: 0; padding: 0; }
.story { border-bottom: 1px solid var(--line); }
.story > a { display: grid; grid-template-columns: 1fr auto; column-gap: 16px; padding: 16px 0; text-decoration: none; }
.story .text { min-width: 0; }
.story h3 { margin: 8px 0 0; font: 600 17px/1.3 var(--head); letter-spacing: -0.01em; text-wrap: pretty; }
.story p.dek { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumb { width: 84px; height: 84px; border-radius: 6px; object-fit: cover; background: var(--line); align-self: start; margin-top: 4px; }
.story.read h3, .lead.read h2 { color: var(--read); }

/* Same story, other papers */
.also { margin: -8px 0 0; padding: 0 0 16px; font-size: 13px; color: var(--ink-3); }
.lead + .also { margin-top: 0; padding-top: 12px; border-bottom: 1px solid var(--line); }
.also summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.also summary::-webkit-details-marker { display: none; }
.also summary svg { width: 14px; height: 14px; transition: transform 150ms var(--ease); }
.also[open] summary svg { transform: rotate(90deg); }
.also ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.also li a { display: grid; gap: 4px; text-decoration: none; padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.also li .t { font: 500 15px/1.3 var(--head); color: var(--ink); }

/* New since last visit */
.divider { display: flex; align-items: center; gap: 12px; margin: 24px 0 0; font-size: 12px; color: var(--ink-3); }
.divider::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }

.more {
  display: block; width: 100%; margin: 24px 0 0; height: 44px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: none;
  font-size: 14px; font-weight: 500; color: var(--ink-2); cursor: pointer;
}
.more:active { background: var(--press); }

/* Loading placeholders: static, no shimmer */
.ph { height: 12px; border-radius: 4px; background: var(--line); margin: 12px 0; }
.ph.img { height: auto; aspect-ratio: 16 / 10; border-radius: 8px; margin-top: 20px; }
.ph.h { height: 20px; }

/* ---------- Papers (settings) ---------- */
.paper-list { list-style: none; margin: 8px 0 0; padding: 0; }
.paper-list li { display: flex; align-items: center; gap: 4px; min-height: 56px; border-bottom: 1px solid var(--line); }
.paper-list .name { flex: 1; min-width: 0; text-decoration: none; padding: 12px 0; display: grid; gap: 2px; }
.paper-list .name .paper { font-size: 15px; color: var(--ink); }
.paper-list .name small { color: var(--ink-3); font-size: 12px; padding-left: 11px; font-variant-numeric: tabular-nums; }
.paper-list li.off .name .paper { color: var(--ink-3); }
.switch { position: relative; width: 40px; height: 24px; flex: none; margin-left: 4px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: var(--line-strong); transition: background-color 150ms var(--ease); pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 9px; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); transition: transform 150ms var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
@media (prefers-color-scheme: dark) { .switch input:checked + span::after { background: var(--bg); } }
.switch input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }
.move { width: 32px; height: 40px; }
.move svg { width: 18px; height: 18px; }
.move:disabled { opacity: 0.3; cursor: default; }
.text-btn { border: 0; background: none; color: var(--link); font-size: 14px; font-weight: 500; padding: 12px 0; cursor: pointer; }

/* ---------- Login ---------- */
.login { min-height: calc(100dvh - var(--bar-h) - 64px); display: flex; align-items: flex-start; }
.login-card { width: 100%; max-width: 360px; margin: 18vh auto 0; display: grid; gap: 8px; }
.login-mark { margin: 0; font: 700 34px/1.05 var(--head); letter-spacing: -0.025em; }
.login-date { margin: 0 0 24px; font-size: 13px; color: var(--ink-3); }
.login-label { font-size: 13px; color: var(--ink-2); }
.login-card input {
  height: 48px; padding: 0 12px; font-size: 17px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
}
.login-card input:focus { outline: none; border-color: var(--ink-3); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: none; font-size: 15px; font-weight: 500; text-decoration: none; cursor: pointer;
  transition: background-color 120ms var(--ease), transform 120ms var(--ease);
}
.btn:active { transform: scale(0.98); background: var(--press); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn svg { width: 16px; height: 16px; }
.error { color: #b3261e; font-size: 14px; min-height: 20px; margin: 4px 0 0; }
@media (prefers-color-scheme: dark) { .error { color: #f2a097; } }

/* ---------- Reader ---------- */
.reader { padding-top: 20px; }
.reader .r-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-3); }
.reader h1 {
  margin: 12px 0 0; font: 700 29px/1.13 var(--head);
  letter-spacing: -0.022em; text-wrap: balance;
}
.reader .dek { margin: 12px 0 0; font: 18px/1.5 var(--reading); color: var(--ink-2); }
.reader .byline { margin: 12px 0 0; font-size: 13px; color: var(--ink-2); }
.reader .lead-img { display: block; width: calc(100% + 32px); margin: 20px -16px 0; aspect-ratio: 16 / 10; object-fit: cover; background: var(--line); }
.reader .body { margin-top: 24px; font: var(--reader-size)/1.65 var(--reading); overflow-wrap: break-word; }
.reader .body > :first-child { margin-top: 0; }
.reader .body p { margin: 0 0 1em; }
.reader .body h2, .reader .body h3, .reader .body h4 { font: 600 1.05em/1.3 var(--head); margin: 1.6em 0 0.5em; }
.reader .body img { display: block; max-width: 100%; height: auto; margin: 1.2em auto; border-radius: 6px; }
.reader .body figure { margin: 1.2em 0; }
.reader .body figcaption { font: 13px/1.4 var(--sans); color: var(--ink-3); margin-top: -0.6em; }
.reader .body blockquote { margin: 1.2em 0; padding-left: 16px; border-left: 2px solid var(--line-strong); color: var(--ink-2); }
.reader .body a { color: var(--link); text-underline-offset: 2px; }
.reader .body ul, .reader .body ol { padding-left: 1.2em; }
.reader .body table { display: block; overflow-x: auto; font: 14px var(--sans); border-collapse: collapse; }
.reader .body td, .reader .body th { border: 1px solid var(--line); padding: 6px 8px; }
.reader .notice { margin: 24px 0 0; padding: 16px; border: 1px solid var(--line-strong); border-radius: 12px; display: grid; gap: 12px; }
.reader .notice p { margin: 0; color: var(--ink-2); font-size: 15px; }
.reader .notice .btn { justify-self: start; }
.reader .source-foot { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--line); display: grid; gap: 12px; justify-items: start; }
.reader .credit { font-size: 12px; color: var(--ink-3); }
.reader .also-read { margin-top: 32px; }
.reader .also-read h2, .reader .next h2 { margin: 0 0 8px; font-size: 13px; font-weight: 500; color: var(--ink-3); }
.reader .next { margin-top: 32px; }
.reader .next a {
  display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px;
  padding: 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); text-decoration: none;
}
.reader .next .t { margin-top: 8px; font: 600 18px/1.25 var(--head); letter-spacing: -0.01em; }
.reader .next svg { color: var(--ink-3); }

@media (min-width: 720px) {
  .reader .lead-img { width: 100%; margin: 24px 0 0; border-radius: 8px; }
  .lead h2 { font-size: 32px; }
}

/* One short fade for page content after a route change */
.view.enter { animation: enter 180ms var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) {
  .view.enter, .icon-btn.spinning svg { animation: none; }
}

/* Native search clear button in the ink colour instead of the system blue */
.search-form input::-webkit-search-cancel-button { filter: grayscale(1); opacity: 0.6; }

/* ---------- Settings ---------- */
.group-title { margin: 24px 0 0; font: 600 13px/1.3 var(--sans); color: var(--ink-3); }
.setting { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.s-text { flex: 1; min-width: 0; }
.s-name { margin: 0; font-size: 15px; font-weight: 500; }
.s-note { margin: 4px 0 0; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.setting .btn { height: 36px; flex: none; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Listen ---------- */
.player {
  position: fixed; left: 8px; right: 8px; z-index: 25;
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 8px);
  max-width: 664px; margin: 0 auto;
  display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 4px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}
.player .icon-btn { color: var(--ink); }
.player-text { flex: 1; min-width: 0; display: grid; text-decoration: none; padding: 0 4px; }
.player-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-pos { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.speed { height: 32px; min-width: 48px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 8px; background: none; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; cursor: pointer; }
body.listening main { padding-bottom: 72px; }
.reader .speaking { background: color-mix(in srgb, var(--link) 12%, transparent); border-radius: 4px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--link) 12%, transparent); }
