/* Blackout — daily erasure poetry
   Two themes: "paper" (a lit desk) and "ink" (a dark room). In both, the page you
   work on stays paper-white, because a blackout bar has to read as black ink. */

:root {
  --bg: #e7e1d5;
  --bg-grain: rgba(20, 17, 13, 0.035);
  --panel: #fbf8f1;
  --panel-2: #f2ede2;
  --text: #17140f;
  --muted: #6d6558;
  --line: rgba(23, 20, 15, 0.14);
  --line-soft: rgba(23, 20, 15, 0.07);
  --accent: #b03a24;
  --accent-soft: rgba(176, 58, 36, 0.1);

  --paper: #fbf8f1;
  --paper-edge: rgba(23, 20, 15, 0.1);
  --ink: #16130e;
  --mark: rgba(255, 205, 41, 0.6);
  --mark-edge: rgba(214, 158, 0, 0.55);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23, 20, 15, 0.06), 0 12px 32px -18px rgba(23, 20, 15, 0.4);
}

[data-theme='ink'] {
  --bg: #121110;
  --bg-grain: rgba(255, 255, 255, 0.025);
  --panel: #1c1a17;
  --panel-2: #232019;
  --text: #ece6da;
  --muted: #978e80;
  --line: rgba(255, 255, 255, 0.13);
  --line-soft: rgba(255, 255, 255, 0.07);
  --accent: #e2704f;
  --accent-soft: rgba(226, 112, 79, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px -20px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 1px 1px, var(--bg-grain) 1px, transparent 0) 0 0 / 4px 4px,
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

button { font: inherit; color: inherit; cursor: pointer; }

/* ---------------- top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  text-decoration: none;
  color: inherit;
  font-weight: 700;
  letter-spacing: 0.14em;
  font-size: 0.95rem;
  background: none;
  border: 0;
  padding: 0;
}

.brand__bar {
  background: var(--text);
  color: var(--bg);
  padding: 0.1em 0.35em 0.15em;
  border-radius: 2px;
}

.nav { display: flex; gap: 0.25rem; margin-left: auto; }

.nav__tab {
  background: none;
  border: 0;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav__tab:hover { color: var(--text); background: var(--line-soft); }
.nav__tab.is-on { color: var(--text); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 0.9rem;
}

.icon-btn:hover { border-color: var(--muted); }

/* ---------------- layout ---------------- */

main { padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 4vw, 2.5rem) 6rem; }

.view { display: none; max-width: 1240px; margin: 0 auto; }
.view.is-on { display: block; }

.kicker {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* ---------------- studio ---------------- */

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: clamp(1.25rem, 3vw, 2.25rem);
  align-items: start;
}

.pagebar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.pagebar__title {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.15;
  margin: 0.4rem 0 0.2rem;
  font-weight: 600;
}

.pagebar__credit { margin: 0; color: var(--muted); font-size: 0.85rem; font-style: italic; }

.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* the sheet of paper */

.sheet {
  background: var(--paper);
  border-radius: 4px;
  border: 1px solid var(--paper-edge);
  box-shadow: var(--shadow);
  padding: clamp(1.5rem, 4vw, 3.25rem) clamp(1.25rem, 4vw, 3.5rem);
  position: relative;
}

.sheet::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  pointer-events: none;
  box-shadow: inset 0 0 60px rgba(23, 20, 15, 0.04);
}

.hint {
  margin: 0.9rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.hint kbd {
  font-family: var(--sans);
  font-size: 0.72rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
}

/* ---------------- the page itself ---------------- */

.page {
  position: relative;
  font-family: var(--serif);
  font-size: clamp(1rem, 1.05vw + 0.7rem, 1.12rem);
  line-height: 2.25;
  color: var(--ink);
  text-align: justify;
  hyphens: none;
  white-space: pre-wrap;
  word-break: normal;
}

.page .w { border-radius: 2px; padding: 0.05em 0.06em; }

.page.is-editing { -webkit-user-select: none; user-select: none; cursor: pointer; }
.page.is-editing .w:hover { background: var(--line-soft); }

.page .w.is-kept {
  background: var(--mark);
  box-shadow: 0 0 0 0.12em var(--mark);
  border-radius: 3px;
}

.page.is-blackout .w.is-kept {
  background: none;
  box-shadow: none;
  font-weight: 600;
}

/* bars: a crisp redaction. Retired from the studio, but poems saved with it still
   render. Square corners matter — a box-shadow spread inherits the border radius,
   and any rounding leaves notches where two words meet. */
.page--bars .w.is-ink,
.page--bars .s.is-ink {
  color: transparent;
  background: var(--ink);
  box-shadow: 0 0 0 0.14em var(--ink);
  border-radius: 0;
}

/* wash: the canvas floods the whole page, so the erased words keep their ink and
   stay faintly legible underneath — which is exactly what happens on paper. */
.page--wash.is-blackout .w.is-kept {
  font-weight: 600;
}

/* marker: drawn by hand on the canvas above, so the spans only hide their text */
.page__ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.page--marker.is-blackout .w.is-ink,
.page--marker.is-blackout .s.is-ink {
  background: none;
  box-shadow: none;
  color: transparent;
}

/* whiteout: the words are simply not there any more */
.page--whiteout .w.is-ink,
.page--whiteout .s.is-ink {
  background: var(--paper);
  box-shadow: 0 0 0 0.14em var(--paper);
  color: transparent;
}

.page--whiteout.is-editing .w.is-ink { background: none; box-shadow: none; color: var(--ink); }

/* miniature version used on feed cards */
.page--mini {
  font-size: 0.56rem;
  line-height: 2.1;
  text-align: justify;
}

/* ---------------- side panels ---------------- */

.studio__side { position: sticky; top: 5.2rem; display: grid; gap: 1rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.panel__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0;
}

.panel__row + .panel__row { border-top: 1px solid var(--line-soft); }
.panel__row--btns { gap: 0.5rem; padding-top: 0.7rem; }

.label { font-size: 0.78rem; color: var(--muted); font-weight: 500; }

.seg {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.seg button {
  border: 0;
  background: none;
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 0.78rem;
  color: var(--muted);
  transition: all 0.15s ease;
}

.seg button:hover { color: var(--text); }
.seg button.is-on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }

.ghost {
  flex: 1;
  border: 1px solid var(--line);
  background: none;
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--muted); }
.ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.ghost--wide { width: 100%; padding: 0.55rem 0.6rem; }

.panel--poem { display: grid; gap: 0.8rem; }

.count { float: right; letter-spacing: 0.04em; text-transform: none; }

.poem {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.55;
  min-height: 4.5rem;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.2rem 0;
}

.poem p { margin: 0 0 0.18rem; }
.poem__empty { color: var(--muted); font-family: var(--sans); font-size: 0.85rem; font-style: italic; }

.field { display: grid; gap: 0.3rem; }
.field span { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.field input {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.field input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.primary {
  border: 0;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.primary:hover:not(:disabled) { transform: translateY(-1px); }
.primary:disabled { opacity: 0.35; cursor: not-allowed; }

.fineprint { margin: 0; font-size: 0.72rem; color: var(--muted); text-align: center; }

/* sticky action bar, small screens only */

.mobilebar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  gap: 0.6rem;
  align-items: center;
  padding: 0.7rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.mobilebar .count { float: none; font-size: 0.8rem; color: var(--muted); margin-right: auto; }
.mobilebar .primary { padding: 0.55rem 1rem; }

/* ---------------- feed ---------------- */

.feed__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.feed__head h1 {
  font-family: var(--serif);
  font-size: clamp(1.7rem, 3.4vw, 2.4rem);
  margin: 0.35rem 0 0.25rem;
  font-weight: 600;
}

.sub { margin: 0; color: var(--muted); font-size: 0.86rem; }

.day { margin-bottom: 2.5rem; }

.day__head {
  position: sticky;
  top: 3.6rem;
  z-index: 20;
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.55rem 0;
  margin-bottom: 1rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.day__label { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; }
.day__date { font-size: 0.8rem; color: var(--muted); }
.day__count { margin-left: auto; font-size: 0.75rem; color: var(--muted); }

.cards { columns: 3 260px; column-gap: 1.15rem; }

.card {
  break-inside: avoid;
  display: flow-root;
  width: 100%;
  margin: 0 0 1.15rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 0.85rem;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover { border-color: color-mix(in srgb, var(--muted) 50%, transparent); }

.card.is-fresh {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}

.card__title {
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-style: italic;
}

.card__poem { font-family: var(--serif); font-size: 1.15rem; line-height: 1.5; }
.card__poem p { margin: 0 0 0.12rem; }

.card__source {
  margin: 0.9rem 0 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.75rem;
  color: var(--muted);
}

.card__source em { font-style: normal; color: var(--text); }

.card__foot {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.vote {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: none;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  transition: all 0.15s ease;
}

.vote:hover { border-color: var(--accent); color: var(--accent); }
.vote.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.vote__arrow { font-size: 0.7rem; line-height: 1; }

.link {
  border: 0;
  background: none;
  padding: 0.28rem 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  border-radius: 6px;
}

.link:hover { color: var(--text); background: var(--line-soft); }

.who { margin-left: auto; font-size: 0.76rem; color: var(--muted); }

.badge {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0.05rem 0.28rem;
  margin-left: 0.35rem;
}

.card__page {
  margin-top: 0.85rem;
  background: var(--paper);
  border: 1px solid var(--paper-edge);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  max-height: 260px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent);
  mask-image: linear-gradient(to bottom, #000 78%, transparent);
}

.card__page[hidden] { display: none; }

.empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translate(-50%, 1.5rem);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 60;
}

.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- responsive ---------------- */

@media (max-width: 940px) {
  .studio { grid-template-columns: 1fr; }
  .studio__side { position: static; }
  .mobilebar { display: flex; }
  main { padding-bottom: 5.5rem; }
  .day__head { top: 3.4rem; }
}

@media (max-width: 620px) {
  .page { line-height: 2.35; text-align: left; }
  .cards { columns: 1; }
  .nav__tab { padding: 0.45rem 0.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------------- added when the backend arrived ---------------- */

/* An author `display` rule beats the UA stylesheet's [hidden] { display: none },
   so .field { display: grid } was keeping hidden panels on screen. */
[hidden] { display: none !important; }

/* was an inline style attribute; moved here so the production CSP can be
   default-src 'self' with no unsafe-inline anywhere */
#mobilePreview { flex: 0 0 auto; }

.field span i {
  font-style: normal;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted);
  opacity: 0.8;
}

.signed {
  margin: 0;
  font-size: 0.9rem;
  font-family: var(--serif);
}

.signed .link { font-size: 0.78rem; margin-left: 0.3rem; }

.fineprint--left { text-align: left; display: block; margin-top: 0.35rem; }

.offline {
  position: fixed;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--accent);
  color: #fff;
  font-size: 0.82rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 2rem);
  text-align: center;
}

.offline[hidden] { display: none; }

.feed__loading,
.feed__error {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.feed__error { color: var(--accent); }

.day__head .day__count.is-loading { opacity: 0.5; }
