/* Daily — Analog-inspired paper planner.
   Palette and type are the whole identity: one desk, one paper, one ink, one gold. */

:root {
  --desk: #e9e4d8;
  --paper: #fbf8f1;
  --paper-edge: #f1ecdf;
  --ink: #2c2a24;
  --ink-faint: #8d8677;
  --rule: #dad3c2;
  --gold: #b3872a;
  --gold-soft: #c9a44c;
  --shadow: 0 1px 2px rgba(44, 42, 36, 0.08), 0 6px 18px rgba(44, 42, 36, 0.07);
  /* the notebook: cognac leather cover, kraft-tinted business page, black elastic */
  --paper-kraft: #f4edda;
  --leather: #8a5a33;
  --leather-dark: #5a3719;
  --leather-shadow: 0 2px 4px rgba(30, 16, 4, 0.25), 0 16px 34px rgba(30, 16, 4, 0.28);
  --stitch: rgba(255, 228, 185, 0.38);
  --elastic: #2a2119;
  --gutter: rgba(70, 45, 20, 0.26);
  --sheet-edge: rgba(70, 45, 20, 0.18);
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --desk: #15130f;
    --paper: #211e18;
    --paper-edge: #191713;
    --ink: #e6e0d2;
    --ink-faint: #7e7768;
    --rule: #37332a;
    --gold: #cba34e;
    --gold-soft: #b3872a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 22px rgba(0, 0, 0, 0.35);
    --paper-kraft: #241f16;
    --leather: #43301f;
    --leather-dark: #24170c;
    --leather-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), 0 16px 34px rgba(0, 0, 0, 0.5);
    --stitch: rgba(255, 220, 170, 0.16);
    --elastic: #0d0a07;
    --gutter: rgba(0, 0, 0, 0.55);
    --sheet-edge: rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* long-pressable surfaces must not trigger iOS text selection / callout */
.slot, .row .txt, .dslot, .habit {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- header ---------- */

header {
  max-width: 880px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 20px 6px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.date {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.45rem;
  letter-spacing: 0.01em;
}

.scores {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.scores b { color: var(--ink); font-weight: 600; }

.scores { cursor: pointer; }

.scores-help {
  max-width: 880px;
  margin: 2px auto 0;
  padding: 0 20px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-faint);
  font-style: italic;
}

.dots { display: inline-flex; gap: 4px; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--rule);
}

.dot.perfect { background: var(--gold); border-color: var(--gold); }

.streak-chip {
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.repair {
  max-width: 880px;
  margin: 2px auto 0;
  padding: 0 20px;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.repair button {
  color: var(--gold);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- no zero days callout ---------- */

.habits {
  /* aligned to the cards' text column, not the header's */
  max-width: min(848px, 100% - 32px);
  margin: 10px auto 0;
  padding: 9px 14px;
  background: linear-gradient(var(--paper), var(--paper) 92%, var(--paper-edge));
  border-left: 2px solid var(--gold);
  border-radius: 4px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 16px;
}

.habits[hidden] { display: none; }

.habits-label {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.habit {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  font-size: 0.85rem;
  color: var(--ink-faint);
  text-align: left;
}

.habit.done { color: var(--ink); }

.habit .mark {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1;
  color: var(--paper);
}

.habit.done .mark {
  background: var(--gold);
  border-color: var(--gold);
  animation: pop 0.35s ease-out 1;
}

.habit.done .mark::after { content: "✓"; }

.habit .count {
  color: var(--gold);
  font-weight: 600;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- view tabs ---------- */

nav {
  max-width: 880px;
  margin: 10px auto 14px;
  padding: 0 20px;
  display: flex;
  gap: 18px;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

nav button { padding: 4px 0; letter-spacing: inherit; color: inherit; }

nav button.active {
  color: var(--ink);
  border-bottom: 2px solid var(--gold);
}

/* ---------- the notebook ---------- */

main { max-width: 880px; margin: 0 auto; padding: 0 16px; }

/* the backlog bench needs elbow room: cards beside lists */
main:has(.backlog) { max-width: 1200px; }

/* A Traveler's Notebook lying open: leather cover, stitched edge, black elastic
   through the spine, two facing pages. Personal is the left page, Business the
   right. Pages stack vertically when the cover is too narrow for a spread. */

.notebook {
  container-type: inline-size;
  position: relative;
  padding: 18px;
  border-radius: 12px;
  background:
    radial-gradient(120% 90% at 12% 0%, rgba(255, 255, 255, 0.13), transparent 55%),
    radial-gradient(100% 80% at 100% 100%, rgba(0, 0, 0, 0.32), transparent 60%),
    repeating-linear-gradient(112deg, rgba(0, 0, 0, 0.045) 0 2px, transparent 2px 6px),
    linear-gradient(var(--leather), var(--leather-dark));
  box-shadow: var(--leather-shadow);
  overflow: hidden;
}

/* saddle stitching just inside the cover edge */
.notebook::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1.5px dashed var(--stitch);
  border-radius: 8px;
  pointer-events: none;
}

.spread {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  border-radius: 3px;
  /* the rest of the insert's sheets peeking out beneath the open pages */
  box-shadow:
    0 0 0 1px var(--sheet-edge),
    0 3px 0 -1px var(--paper-edge),
    0 3px 0 0 var(--sheet-edge),
    0 6px 0 -2px var(--paper-edge),
    0 6px 0 -1px var(--sheet-edge);
}

/* the elastic through the spine, running the full height of the cover */
.spread::before {
  content: "";
  display: none;
  position: absolute;
  top: -18px;
  bottom: -18px;
  left: 50%;
  width: 5px;
  margin-left: -2.5px;
  border-radius: 3px;
  background: linear-gradient(90deg, #100c09, var(--elastic) 45%, #5a4a3c 62%, #100c09);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.55);
  z-index: 3;
  pointer-events: none;
}

/* the fold shadow in the gutter */
.spread::after {
  content: "";
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 60px;
  margin-left: -30px;
  background: linear-gradient(90deg, transparent, var(--gutter) 50%, transparent);
  z-index: 2;
  pointer-events: none;
}

.card {
  position: relative;
  background: var(--paper);
  padding: 16px 18px 14px;
  min-width: 0;
}

.card.page-l { border-radius: 3px 3px 0 0; }

.card.page-r {
  background: var(--paper-kraft);
  border-radius: 0 0 3px 3px;
  border-top: 1px solid var(--rule);
}

@container (min-width: 560px) {
  .spread { grid-template-columns: 1fr 1fr; }
  .spread::before, .spread::after { display: block; }
  .card.page-l { border-radius: 3px 0 0 3px; }
  .card.page-r { border-radius: 0 3px 3px 0; border-top: none; }
}

.card.celebrate { animation: glow 1.1s ease-out 1; }

@keyframes glow {
  0% { box-shadow: none; }
  30% { box-shadow: inset 0 0 0 3px var(--gold-soft); }
  100% { box-shadow: none; }
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
}

.card-title {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.direction {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ink-faint);
  text-align: right;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.direction input {
  font: inherit;
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 1px dashed var(--rule);
  width: 100%;
  text-align: right;
  padding: 0 0 1px;
}

.direction input::placeholder { color: var(--ink-faint); opacity: 0.7; }

/* slot rows are the ruled lines of the card */

.slot {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  border-top: 1px solid var(--rule);
  width: 100%;
  text-align: left;
}

.slot .sig {
  flex: 0 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
}

.slot .txt {
  position: relative;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot .txt::after {
  content: "";
  position: absolute;
  left: 0;
  top: 54%;
  height: 1.5px;
  width: 0;
  background: currentColor;
  transition: width 0.28s ease-out;
}

.slot.done .txt { color: var(--ink-faint); }
.slot.done .txt::after { width: 100%; }

.slot.empty {
  color: var(--ink-faint);
  font-size: 0.85rem;
  font-style: italic;
}

.slot.win { font-weight: 600; font-size: 1.02rem; }

.star { width: 17px; height: 17px; fill: none; stroke: var(--gold); stroke-width: 1.6; }
.slot.done .star, .star.filled { fill: var(--gold); animation: pop 0.35s ease-out 1; }

@keyframes pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.45); }
  100% { transform: scale(1); }
}

.circle {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.6px solid var(--ink-faint);
}

.slot.done .circle { background: var(--ink-faint); }

.smalls-rule {
  border-top: 1px dashed var(--rule);
  margin-top: 2px;
  padding-top: 2px;
}

.slot.small { min-height: 36px; font-size: 0.92rem; }
.slot.small .sig::before { content: "·"; font-size: 1.3rem; line-height: 0; }

/* ---------- shelf (morning planning) ---------- */

.shelf { margin-top: 26px; }

.shelf h2, .backlog h2 {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 18px 4px 6px;
}

.shelf h2 em { font-style: normal; color: var(--gold); }

.rows { display: flex; flex-direction: column; gap: 6px; }

.row {
  display: flex;
  flex-wrap: wrap; /* buttons drop below the text instead of crushing it */
  align-items: center;
  gap: 6px 8px;
  background: var(--paper);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(44, 42, 36, 0.07);
  padding: 10px 12px;
  min-height: 44px;
}

.row .txt { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }

.row .grab {
  color: var(--ink-faint);
  cursor: grab;
  touch-action: none;
  padding: 4px 2px;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

.row.sortable-ghost { opacity: 0.4; }

.tag {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
}

.row .act {
  font-size: 0.78rem;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 4px 9px;
  white-space: nowrap;
}

.row .act.primary {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
  font-weight: 500;
}

.row .act:active { transform: scale(0.96); }

.row .act.icon {
  padding: 4px 8px;
  font-size: 0.85rem;
  line-height: 1;
}

/* ---------- confirm modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.modal-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 22px 22px 16px;
  width: min(92vw, 360px);
}

.modal-card p { margin: 0 0 18px; overflow-wrap: anywhere; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-cancel {
  color: var(--ink-faint);
  padding: 8px 14px;
}

.modal-confirm {
  background: var(--ink);
  color: var(--paper);
  border-radius: 5px;
  padding: 8px 16px;
  font-weight: 600;
}

/* ---------- backlog view ---------- */

.backlog-grid { display: grid; gap: 18px; }

@media (min-width: 1000px) {
  .backlog-grid { grid-template-columns: 360px 1fr; gap: 26px; align-items: start; }
  .backlog-cards { position: sticky; top: 14px; }
}

.card.mini { padding: 10px 14px 8px; }
.card.mini .slot { min-height: 38px; }
.card.mini .slot.small { min-height: 30px; }
.card.mini .card-head { padding-bottom: 4px; }

.drop-zone { min-height: 38px; }

.drop-zone .sortable-ghost {
  opacity: 0.6;
  background: color-mix(in srgb, var(--gold) 12%, transparent);
  border-radius: 4px;
}

.backlog .domain-cols { display: grid; gap: 8px; }

/* two ready columns only when the lists pane is truly wide enough */
@media (min-width: 720px) and (max-width: 999px) {
  .backlog .domain-cols { grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
}

@media (min-width: 1240px) {
  .backlog .domain-cols { grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
}

/* the Ready cap is soft — over-cap is shown, never silently corrected */

.cap { font-variant-numeric: tabular-nums; }

.cap-over {
  color: var(--ink);
  font-weight: 600;
  background: color-mix(in srgb, var(--gold) 22%, transparent);
  border-radius: 3px;
  padding: 1px 6px;
}

.cap-note {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95em;
  text-transform: none;
  letter-spacing: 0.01em;
  color: var(--gold);
  margin-left: 7px;
}

.chip {
  font-size: 0.74rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 2px 7px;
  color: var(--ink-faint);
}

.parked-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.parked-head input {
  font: inherit;
  font-size: 0.85rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 5px 9px;
  width: 150px;
}

.muted { color: var(--ink-faint); font-size: 0.85rem; margin: 8px 4px; }

.done-row { color: var(--ink-faint); }
.done-row .when {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.done-row .struck { text-decoration: line-through; }

/* ---------- sparks ---------- */

.sparks { max-width: 640px; margin: 0 auto; }

.sparks-intro { text-align: center; font-style: italic; margin-bottom: 20px; }

.spark {
  display: flex;
  align-items: baseline;
  gap: 12px;
  background: var(--paper);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(44, 42, 36, 0.07);
  padding: 14px 16px;
  margin-bottom: 8px;
}

.spark .txt {
  flex: 1;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.spark .txt::first-letter { color: var(--gold); }

.spark .act.icon {
  font-size: 0.8rem;
  color: var(--ink-faint);
  border: none;
  opacity: 0.5;
}

/* ---------- quick add ---------- */

.quick {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--desk) 30%);
}

.quick form {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
}

.quick input {
  flex: 1;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

.quick input::placeholder { color: var(--ink-faint); }

.quick button {
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  padding: 0 18px;
  font-weight: 600;
}

.edit-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--ink);
  background: none;
  border: none;
  border-bottom: 1px dashed var(--gold);
  padding: 0 0 1px;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  display: flex;
  gap: 14px;
  align-items: center;
  max-width: min(92vw, 480px);
  z-index: 10;
}

.toast button { color: var(--gold-soft); font-weight: 600; }

/* ---------- closed (evening) ---------- */

.closed-summary {
  font-family: var(--font-display);
  font-style: italic;
  text-align: center;
  color: var(--ink-faint);
  padding: 30px 0 6px;
  font-size: 1.05rem;
}

.close-day {
  display: block;
  margin: 26px auto 0;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

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