/* Dinapatra on the web: the paper's own look — Noto Serif display type on
   cream newsprint, ink-black rules — with a dark mode for reading at night. */

:root {
  color-scheme: light;
  --paper: #f4efe3;
  --paper-2: #ebe4d3;
  --card: #fbf8f1;
  --ink: #1a1813;
  --muted: #6b6457;
  --rule: #d5ccb8;
  --accent: #9a3412;
  --green: #15803d;
  --danger: #b91c1c;
  --serif: "Noto Serif", Georgia, "Times New Roman", serif;
  --sans: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #151410;
    --paper-2: #1f1d17;
    --card: #1b1a15;
    --ink: #efe9dc;
    --muted: #a49c8c;
    --rule: #3a3629;
    --accent: #f08a5d;
    --green: #4ade80;
    --danger: #f87171;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; }

button, input { font: inherit; color: inherit; }

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

.wrap { width: min(1040px, 100% - 32px); margin-inline: auto; }

/* ---------------------------------------------------------------- masthead */
.masthead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 3px double var(--ink);
}

.masthead-inner {
  width: min(1040px, 100% - 32px);
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 0;
}

.nameplate {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.tabs { display: flex; gap: 4px; }

.tabs a {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
}

.tabs a[aria-current="page"] { color: var(--paper); background: var(--ink); }

.account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 0;
}

.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

.link-button {
  background: none;
  border: 0;
  padding: 6px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--ink);
}

@media (max-width: 640px) {
  .masthead-inner { flex-wrap: wrap; gap: 8px 14px; }
  .nameplate { font-size: 1.35rem; }
  .account { width: 100%; justify-content: space-between; order: 3; }
  .who { max-width: 60vw; }
}

main { padding: 28px 0 64px; }

.loading, .notice { text-align: center; color: var(--muted); font-family: var(--sans); padding: 48px 16px; }

/* ------------------------------------------------------------------ sign-in */
.auth {
  width: min(420px, 100% - 32px);
  margin: 6vh auto 0;
  text-align: center;
}

.auth .big {
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 4px double var(--ink);
}

.auth .tagline {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 10px 0 28px;
}

.form {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 22px;
}

.form h2 { margin: 0 0 4px; font-size: 1.25rem; }
.form p { margin: 0 0 16px; color: var(--muted); font-family: var(--sans); font-size: 0.9rem; }

.form label {
  display: block;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 6px;
}

.form input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 1rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.92rem;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  text-decoration: none;
}

.button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.button[disabled] { opacity: 0.6; cursor: progress; }
.form .button { width: 100%; margin-top: 20px; }

.form .row { display: flex; justify-content: space-between; margin-top: 14px; font-family: var(--sans); font-size: 0.86rem; }

.message { margin-top: 14px; font-family: var(--sans); font-size: 0.88rem; }
.message.error { color: var(--danger); }
.message.ok { color: var(--green); }

.fineprint { margin-top: 22px; font-family: var(--sans); font-size: 0.8rem; color: var(--muted); }

/* -------------------------------------------------------------------- today */
.edition-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 20px;
}

.kicker {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}

.edition-head h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4.2vw, 2.4rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.edition-meta { margin: 8px 0 0; font-family: var(--sans); font-size: 0.86rem; color: var(--muted); }

.badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  vertical-align: middle;
  margin-left: 6px;
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 640px) {
  .edition-head { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------- viewer */
.viewer { display: grid; gap: 14px; justify-items: center; }

.viewer canvas {
  display: block;
  width: 100%;
  max-width: 900px;
  height: auto;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 10px 30px rgba(0, 0, 0, .12);
}

.page-slot { width: 100%; max-width: 900px; position: relative; }
.page-slot .page-no { font-family: var(--sans); font-size: 0.74rem; color: var(--muted); text-align: right; margin-top: 4px; }
.page-slot.pending { aspect-ratio: 595 / 842; background: var(--paper-2); border-radius: 4px; }

.progress { font-family: var(--sans); font-size: 0.86rem; color: var(--muted); text-align: center; padding: 24px; }

/* ------------------------------------------------------------------ library */
.library { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 32px; align-items: start; }

@media (max-width: 820px) { .library { grid-template-columns: 1fr; } }

.calendar {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 16px;
  position: sticky;
  top: 86px;
}

@media (max-width: 820px) { .calendar { position: static; } }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h2 { margin: 0; font-size: 1.15rem; }

.cal-nav {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--paper); cursor: pointer;
  font-family: var(--sans); font-size: 1.1rem; line-height: 1;
}
.cal-nav[disabled] { opacity: 0.35; cursor: default; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.cal-dow {
  font-family: var(--sans); font-size: 0.7rem; font-weight: 700; color: var(--muted);
  text-align: center; padding: 4px 0; letter-spacing: 0.06em;
}

.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--muted);
  border: 1px solid transparent;
  background: none;
  text-decoration: none;
}

a.cal-day { color: var(--ink); font-weight: 700; cursor: pointer; }
a.cal-day:hover { background: var(--paper-2); }
.cal-day.today { border-color: var(--ink); }
.cal-day.selected { background: var(--ink); color: var(--paper); }

/* The green dot: a paper exists for this day. */
.cal-day .dot {
  position: absolute;
  bottom: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
}
.cal-day.not-ready .dot { background: var(--danger); }

.legend { display: flex; gap: 14px; margin-top: 12px; font-family: var(--sans); font-size: 0.76rem; color: var(--muted); }
.legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 6px; vertical-align: middle; }
.legend i.red { background: var(--danger); }

.issues { display: grid; gap: 12px; }
.issues h2 { margin: 0 0 4px; font-size: 1.15rem; }

.issue {
  display: block;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 16px 18px;
}

.issue:hover { border-color: var(--ink); }
.issue .date { font-family: var(--sans); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.issue h3 { margin: 4px 0 6px; font-size: 1.08rem; line-height: 1.25; }
.issue ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.92rem; }
.issue .meta { margin-top: 8px; font-family: var(--sans); font-size: 0.78rem; color: var(--muted); }

.empty { color: var(--muted); font-family: var(--sans); padding: 18px; border: 1px dashed var(--rule); border-radius: 14px; text-align: center; }

/* ===================================================================== reader
   The paper lies on a desk under a soft lamp; the controls float beneath it. */

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

#reader-root { margin-top: 4px; }

.reader {
  --desk-1: #e9e1cf;
  --desk-2: #d8ccb2;
  position: relative;
  min-height: calc(100vh - 220px);
  padding: 28px 16px 120px;
  background:
    radial-gradient(1200px 520px at 50% 0%, rgba(255, 252, 240, .85), transparent 70%),
    radial-gradient(900px 600px at 50% 120%, rgba(0, 0, 0, .10), transparent 70%),
    linear-gradient(180deg, var(--desk-1), var(--desk-2));
  border-top: 1px solid var(--rule);
}

@media (prefers-color-scheme: dark) {
  .reader {
    --desk-1: #23201a;
    --desk-2: #14120e;
    background:
      radial-gradient(1100px 520px at 50% 0%, rgba(255, 214, 150, .10), transparent 70%),
      linear-gradient(180deg, var(--desk-1), var(--desk-2));
  }
}

.reader:fullscreen { padding-top: 24px; min-height: 100vh; overflow: auto; }

.stage { display: grid; place-items: center; }

.book {
  margin-inline: auto;
  filter: drop-shadow(0 22px 28px rgba(40, 28, 10, .28)) drop-shadow(0 2px 3px rgba(40, 28, 10, .25));
  transition: filter .4s ease;
}

/* Night paper: warmer, dimmer newsprint for reading in the dark. */
.reader.night .book canvas, .reader.night .closely canvas { filter: sepia(.38) brightness(.74) contrast(1.06) saturate(.9); }

/* ----------------------------------------------------------- the press */
.press { display: grid; justify-items: center; gap: 16px; padding: 80px 16px; color: var(--muted); }
.press-text { font-family: var(--sans); font-size: .92rem; margin: 0; letter-spacing: .02em; }
.press-bar { width: min(320px, 70vw); height: 3px; background: color-mix(in srgb, var(--ink) 12%, transparent); border-radius: 3px; overflow: hidden; }
.press-bar i { display: block; height: 100%; background: var(--ink); transition: width .3s ease; }
.press-roll { display: flex; gap: 10px; }
.press-roll span {
  width: 44px; height: 58px; border-radius: 3px; background: #fbf8f0;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .15);
  animation: press 1.4s ease-in-out infinite;
  background-image: repeating-linear-gradient(180deg, transparent 0 7px, rgba(0, 0, 0, .12) 7px 8px);
  background-size: 70% 100%; background-position: center; background-repeat: no-repeat;
}
.press-roll span:nth-child(2) { animation-delay: .18s; }
.press-roll span:nth-child(3) { animation-delay: .36s; }
@keyframes press { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .press-roll span { animation: none; } }

/* ------------------------------------------------------------- the dock */
.dock {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .35);
  max-width: calc(100vw - 24px);
}

.dock-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .2s ease, transform .15s ease, color .2s ease;
  flex: none;
}
.dock-btn:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); }
.dock-btn:active { transform: scale(.94); }
.dock-btn.toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.dock-btn.toggle[data-act="breeze"][aria-pressed="true"] svg { animation: breeze 3.2s ease-in-out infinite; }
@keyframes breeze { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(2px); } }
@media (prefers-reduced-motion: reduce) { .dock-btn svg { animation: none !important; } }

.dock-sep { width: 1px; height: 24px; background: color-mix(in srgb, var(--ink) 15%, transparent); margin: 0 4px; flex: none; }

.scrub { display: grid; gap: 2px; min-width: 150px; padding: 0 6px; }
.scrub input { width: 100%; accent-color: var(--ink); margin: 0; }
.scrub output { font-family: var(--sans); font-size: .72rem; color: var(--muted); text-align: center; white-space: nowrap; }

@media (max-width: 640px) {
  .dock { gap: 0; padding: 6px; }
  .dock-btn { width: 36px; height: 36px; }
  .scrub { min-width: 90px; }
  .dock-sep, .dock-btn[data-act="full"] { display: none; }
}

/* ----------------------------------------------------------- contents */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(360px, 88vw);
  z-index: 30;
  background: var(--card);
  border-left: 1px solid var(--rule);
  box-shadow: -18px 0 50px rgba(0, 0, 0, .2);
  padding: 18px 16px;
  overflow: auto;
  animation: slide-in .28s ease-out;
}
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px double var(--ink); padding-bottom: 8px; margin-bottom: 8px; }
.drawer-head h2 { margin: 0; font-size: 1.3rem; }
.toc { list-style: none; margin: 0; padding: 0; }
.toc button {
  width: 100%; display: flex; justify-content: space-between; gap: 12px;
  padding: 12px 6px; background: none; border: 0; border-bottom: 1px solid var(--rule);
  font-family: var(--serif); font-size: 1.02rem; text-align: left; cursor: pointer; color: var(--ink);
}
.toc button:hover { background: var(--paper-2); }
.toc-page { font-family: var(--sans); font-size: .8rem; color: var(--muted); align-self: center; }
.toc-empty { color: var(--muted); font-family: var(--sans); padding: 12px 6px; }

/* ------------------------------------------------------- read closely */
.closely {
  position: fixed; inset: 0; z-index: 40;
  background: color-mix(in srgb, #0c0b09 88%, transparent);
  backdrop-filter: blur(6px);
  display: grid; grid-template-rows: auto 1fr;
  animation: fade .2s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.closely-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; color: #efe9dc; font-family: var(--sans); font-size: .9rem;
}
.closely-bar .dock-btn { color: #efe9dc; }
.closely-scroll { overflow: auto; padding: 8px 16px 40px; display: grid; justify-items: center; gap: 18px; touch-action: pan-x pan-y pinch-zoom; }
.closely-scroll canvas { width: min(1100px, 100%); height: auto; background: #fff; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.closely-scroll .press-text { color: #c9c2b2; padding-top: 30vh; }

/* The hidden attribute always wins over a component's display rule. */
[hidden] { display: none !important; }

/* page-flip's own layout rules (the library does not inject them). */
.stf__parent { position: relative; display: block; box-sizing: border-box; transform: translateZ(0); touch-action: pan-y; }
.stf__wrapper { position: relative; width: 100%; height: 100%; box-sizing: border-box; }
.stf__parent canvas { position: absolute; width: 100%; height: 100%; left: 0; top: 0; }
