/* ---------- fonts (local, no CDN) ---------- */

@font-face {
  font-family: "Literata";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "DM Serif Display";
  src: url("assets/dm-serif.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

/* ============================================================
   THE FORTY-EIGHT — a weekend printed as a timetable
   ============================================================ */

:root {
  --paper: #f3eee1;
  --paper-deep: #ebe4d2;
  --card: #fbf7ec;
  --ink: #211d16;
  --ink-soft: #6a6151;
  --rule: #c9bfa6;
  --rule-fine: #ddd4bd;
  --accent: #b3301f;

  --art: #9c4415;
  --film: #4a3e8f;
  --food: #35682f;
  --lit: #27548d;
  --music: #8f3276;
  --outdoors: #22635e;
  --walks: #6d4a28;

  --serif: "Literata", Georgia, "Times New Roman", serif;
  --display: "DM Serif Display", "Literata", Georgia, serif;
  --mono: "IBM Plex Mono", "Courier New", monospace;

  --pad-safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background:
    repeating-linear-gradient(0deg, rgba(33, 29, 22, 0.014) 0 2px, transparent 2px 4px),
    var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.55;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button, select, input { touch-action: manipulation; font: inherit; color: inherit; }

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

::selection { background: var(--accent); color: var(--card); }

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

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 60;
  background: var(--ink); color: var(--paper);
  padding: 0.6rem 1rem; font-family: var(--mono); font-size: 0.85rem;
  text-decoration: none; transition: top 160ms ease;
}
.skip:focus { top: 1rem; }

/* ---------- masthead ---------- */

.masthead { border-bottom: 4px double var(--ink); }
.masthead-inner {
  max-width: 76rem; margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) clamp(1.2rem, 3vw, 2rem);
  display: grid; grid-template-columns: 1fr auto; gap: 0.4rem 2rem; align-items: end;
}
.over {
  grid-column: 1 / -1;
  font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--ink-soft);
}
.wordmark {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(2.9rem, 8vw, 6.2rem);
  line-height: 0.95; letter-spacing: -0.015em;
  text-wrap: balance;
}
.standfirst { max-width: 46ch; color: var(--ink-soft); text-wrap: pretty; }
.standfirst strong { color: var(--ink); font-weight: 600; }
.kept-tally {
  font-family: var(--mono); font-size: 0.9rem; letter-spacing: 0.1em;
  border: 2px solid var(--ink); padding: 0.45rem 0.8rem;
  transform: rotate(2deg); white-space: nowrap;
}
.kept-tally span { color: var(--accent); font-weight: 600; }

/* ---------- toolbar ---------- */

.toolbar-wrap {
  position: sticky; top: 0; z-index: 30;
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
  padding: 0.55rem clamp(1rem, 4vw, 2.5rem);
  padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
}
.toolbar {
  max-width: 76rem; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: end; gap: 0.6rem 1rem;
}
.field { display: flex; flex-direction: column; gap: 0.2rem; }
.field label {
  font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-soft);
}
.field input,
.field select {
  background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 0;
  padding: 0.45rem 0.6rem; min-width: 0;
}
.field input { width: min(21rem, 100%); }
.field select { width: auto; }
.field input::placeholder { color: var(--ink-soft); opacity: 1; }

.btn {
  font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 0;
  padding: 0.55rem 0.9rem; cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.ghost { border-color: var(--rule); color: var(--ink-soft); }
.btn.ghost:hover { border-color: var(--ink); background: var(--paper-deep); color: var(--ink); }
.btn.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--card); }
.btn.toggle[aria-pressed="true"]:hover { background: #8f2113; border-color: #8f2113; }

.count {
  margin-left: auto; align-self: center;
  font-family: var(--mono); font-size: 0.8rem; color: var(--ink-soft);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

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

main { max-width: 76rem; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem) 3rem; }

/* ---------- the 48-hour strip ---------- */

.strip { margin: clamp(1.6rem, 4vw, 2.8rem) 0 2.4rem; }
.strip-head { margin-bottom: 1.1rem; }
.strip-head h2 {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(1.35rem, 2.6vw, 1.8rem); text-wrap: balance;
}
.strip-head p { color: var(--ink-soft); font-size: 0.95rem; }

.ribbon {
  position: relative; height: 128px;
  border: 2px solid var(--ink);
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(12.5% - 1px), var(--rule-fine) calc(12.5% - 1px) 12.5%);
  overflow: visible;
}
.ribbon-day {
  position: absolute; top: 0.35rem;
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink-soft);
}
.ribbon-day.noon { left: 50%; transform: translateX(-50%); }
.midnight {
  position: absolute; top: 0; bottom: 0; left: 50%;
  border-left: 2px dashed var(--rule);
}
.ribbon-scale {
  position: absolute; bottom: 0.3rem;
  transform: translateX(-50%);
  font-family: var(--mono); font-size: 0.62rem; color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.tick {
  position: absolute; bottom: 1.6rem; transform: translateX(-50%);
  background: none; border: 0; padding: 0 5px; cursor: pointer;
  height: 88px; width: 17px;
  display: flex; align-items: flex-end; justify-content: center;
}
.tick .bar {
  position: relative;
  display: block; width: 7px; border-radius: 3px;
  background: currentColor; min-height: 14px;
  transform-origin: bottom;
  transition: transform 140ms ease;
}
.tick .bar::before {
  content: ""; position: absolute; top: -5px; left: 50%; transform: translateX(-50%);
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); opacity: 0; transition: opacity 140ms ease;
}
.tick:hover .bar, .tick:focus-visible .bar { transform: scaleY(1.06); }
.tick:hover .bar::before, .tick:focus-visible .bar::before, .tick.kept .bar::before { opacity: 1; }
.tick.kept .bar { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
.tick.dim { opacity: 0.22; }
.tick::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  font-family: var(--mono); font-size: 0.68rem; line-height: 1.3;
  padding: 0.35rem 0.55rem; text-align: center;
  white-space: normal; width: max-content; max-width: 15rem;
  opacity: 0; pointer-events: none; transition: opacity 140ms ease;
  z-index: 5;
}
.tick:hover::after, .tick:focus-visible::after { opacity: 1; }

/* ---------- timetable list ---------- */

.day { margin-bottom: 2.2rem; scroll-margin-top: 6.5rem; }
.day-head {
  display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--ink); padding-bottom: 0.4rem; margin-bottom: 0.2rem;
}
.day-name {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}
.day-date {
  font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-soft);
}
.day-tally {
  margin-left: auto; font-family: var(--mono); font-size: 0.78rem;
  color: var(--ink-soft); font-variant-numeric: tabular-nums;
}

.entry {
  display: grid; grid-template-columns: 8.6rem 1fr auto;
  gap: 0.4rem 1.4rem; align-items: start;
  padding: 0.95rem 0.6rem 0.95rem 0.9rem;
  border-bottom: 1px solid var(--rule);
  position: relative;
  scroll-margin-top: 6rem;
  transition: background-color 140ms ease;
}
.entry:hover { background: var(--card); }
.entry::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; background: transparent; transition: background-color 140ms ease;
}
.entry.kept::before { background: var(--accent); }

.when {
  font-family: var(--mono); font-size: 1rem; font-weight: 500;
  font-variant-numeric: tabular-nums; line-height: 1.5; padding-top: 0.1rem;
}
.when .end { color: var(--ink-soft); }
.what h3 { font-size: 1.18rem; line-height: 1.3; font-weight: 600; }
.what h3 button {
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: inherit; cursor: pointer; text-align: left;
  touch-action: manipulation;
  text-wrap: balance; overflow-wrap: break-word;
}
.what h3 button:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
.meta { color: var(--ink-soft); font-size: 0.92rem; margin-top: 0.15rem; }
.tag {
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem;
  padding-top: 0.2rem;
}

.stamp {
  display: inline-block;
  font-family: var(--mono); font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  border: 2px solid currentColor; border-radius: 2px;
  padding: 0.28em 0.6em; transform: rotate(-2deg);
  color: var(--ink-soft); white-space: nowrap;
}
.stamp.c-Art { color: var(--art); }
.stamp.c-Film { color: var(--film); }
.stamp.c-Food { color: var(--food); }
.stamp.c-Literature { color: var(--lit); }
.stamp.c-Music { color: var(--music); }
.stamp.c-Outdoors { color: var(--outdoors); }
.stamp.c-Walks { color: var(--walks); }

.stamp.kept-stamp {
  color: var(--accent); transform: rotate(3deg);
}
.entry .kept-stamp { display: none; }
.entry.kept .kept-stamp { display: inline-block; }
.price {
  font-family: var(--mono); font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.price.free { color: var(--food); }

/* ---------- empty state ---------- */

.empty {
  margin: 3rem auto; max-width: 34rem; text-align: center;
  border: 2px dashed var(--rule); padding: 2.4rem 1.6rem;
}
.empty-stamp {
  display: inline-block; font-family: var(--mono); font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase; font-size: 0.85rem;
  color: var(--accent); border: 3px double var(--accent); border-radius: 3px;
  padding: 0.5em 0.9em; transform: rotate(-3deg); margin-bottom: 1.2rem;
}
.empty h2 { font-family: var(--display); font-weight: 400; font-size: 1.7rem; margin-bottom: 0.4rem; }
.empty p { color: var(--ink-soft); margin-bottom: 1.2rem; text-wrap: pretty; }

/* ---------- colophon ---------- */

.colophon {
  border-top: 4px double var(--ink);
  padding: 1.4rem clamp(1rem, 4vw, 2.5rem) calc(1.4rem + var(--pad-safe-b));
  font-family: var(--mono); font-size: 0.75rem; color: var(--ink-soft);
  text-align: center; letter-spacing: 0.04em;
}
.colophon p + p { margin-top: 0.3rem; }

/* ---------- detail sheet (ticket stub) ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(33, 29, 22, 0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 220ms ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed; z-index: 50;
  top: 0; bottom: 0; right: 0;
  width: min(30rem, 100vw);
  background: var(--card);
  border-left: 2px solid var(--ink);
  transform: translateX(103%);
  visibility: hidden;
  transition: transform 260ms ease, visibility 0s linear 260ms;
  box-shadow: -8px 0 24px rgba(33, 29, 22, 0.18);
}
.sheet.open {
  transform: none; visibility: visible;
  transition: transform 260ms ease;
}
.sheet::before {  /* punch holes along the stub edge */
  content: ""; position: absolute; top: 0; bottom: 0; left: -7px; width: 14px;
  background-image: radial-gradient(circle at 50% 12px, var(--paper) 5px, transparent 5.5px);
  background-size: 14px 34px; background-repeat: repeat-y;
}
.sheet-inner {
  height: 100%; overflow-y: auto; overscroll-behavior: contain;
  padding: 1.2rem clamp(1.1rem, 4vw, 1.8rem) calc(1.6rem + var(--pad-safe-b));
}
.sheet-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
}
.icon-btn {
  background: var(--card); border: 2px solid var(--ink); border-radius: 50%;
  width: 2.4rem; height: 2.4rem; cursor: pointer;
  display: grid; place-items: center;
  transition: background-color 140ms ease, color 140ms ease;
}
.icon-btn:hover { background: var(--ink); color: var(--card); }
.d-no {
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 0.5rem;
}
.d-title {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(1.7rem, 5vw, 2.3rem); line-height: 1.12;
  text-wrap: balance; margin-bottom: 1.1rem; overflow-wrap: break-word;
}
.d-facts {
  border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule);
  padding: 0.9rem 0; margin-bottom: 1.1rem;
  display: grid; grid-template-columns: auto 1fr; gap: 0.45rem 1rem;
  font-size: 0.95rem;
}
.d-facts dt {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-soft); padding-top: 0.28em;
}
.d-facts dd { font-variant-numeric: tabular-nums; }
.d-body p { margin-bottom: 0.9rem; text-wrap: pretty; overflow-wrap: break-word; }
.d-body p:first-child { font-size: 1.1rem; }

.btn.save { width: 100%; margin-top: 0.6rem; padding: 0.8rem 1rem; font-size: 0.9rem; }
.btn.save[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--card);
}
.btn.save[aria-pressed="true"]:hover { background: #8f2113; border-color: #8f2113; }

.sheet-foot {
  margin-top: 1.4rem; color: var(--rule); letter-spacing: 0.35em;
  text-align: center; font-size: 0.7rem; overflow: hidden; white-space: nowrap;
}

body.sheet-open { overflow: hidden; }

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

@media (max-width: 860px) {
  .masthead-inner { grid-template-columns: 1fr; }
  .kept-tally { justify-self: start; }
  .count { margin-left: 0; flex-basis: 100%; }
}

@media (max-width: 640px) {
  .ribbon { height: 118px; }
  .entry { grid-template-columns: 1fr; gap: 0.35rem; padding-left: 1rem; }
  .when { padding-top: 0; }
  .tag { flex-direction: row; align-items: center; justify-content: flex-start; gap: 0.8rem; }
  .stamp { transform: rotate(0deg); }
  .field { flex: 1 1 100%; }
  .field input { width: 100%; }

  .sheet {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%;
    max-height: 92vh;
    max-height: 92dvh; border-left: 0; border-top: 2px solid var(--ink);
    border-radius: 14px 14px 0 0;
    transform: translateY(103%);
    box-shadow: 0 -8px 24px rgba(33, 29, 22, 0.2);
  }
  .sheet::before {
    top: -7px; bottom: auto; left: 0; right: 0; width: auto; height: 14px;
    background-image: radial-gradient(circle at 12px 50%, var(--paper) 5px, transparent 5.5px);
    background-size: 34px 14px; background-repeat: repeat-x;
  }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .skip { transition: none; }
}
