/* ============================================================
   THE WEEKEND ALMANAC — a two-day listings paper
   Paper #f6f1e7 · Ink #211c14 · Vermilion #a83a0c
   Type: Oswald (poster) · Literata (prose) · Plex Mono (data)
   ============================================================ */

@font-face {
  font-family: "Almanac Serif";
  src: url("assets/literata.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal italic;
  font-display: swap;
}
@font-face {
  font-family: "Almanac Poster";
  src: url("assets/oswald.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Almanac Mono";
  src: url("assets/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --paper: #f6f1e7;
  --paper-bright: #fbf7ee;
  --paper-deep: #ece4d2;
  --ink: #211c14;
  --ink-soft: #5c5546;
  --rule: rgba(33, 28, 20, 0.26);
  --accent: #a83a0c;
  --accent-deep: #8f2f0a;
  --scrim: rgba(26, 21, 14, 0.55);
  --hard-shadow: 8px 8px 0 rgba(33, 28, 20, 0.14);
  --serif: "Almanac Serif", Literata, Georgia, "Times New Roman", serif;
  --poster: "Almanac Poster", Oswald, "Arial Narrow", sans-serif;
  --mono: "Almanac Mono", "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
  border-top: 6px solid var(--accent);
  min-height: 100vh;
}

/* Faint paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='180' height='180' filter='url(%23n)' opacity='0.045'/></svg>");
}

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

[hidden] { display: none !important; }

body.no-scroll { overflow: hidden; }

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

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

/* ---------- Masthead ---------- */

.masthead {
  padding: 18px 20px 0;
}

.masthead-inner {
  max-width: 1240px;
  margin: 0 auto;
}

.microline {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 18px;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.masthead-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px 32px;
  align-items: end;
}

.wordmark {
  margin: 0;
  font-family: var(--poster);
  font-weight: 700;
  font-size: clamp(46px, 7.4vw, 96px);
  line-height: 0.92;
  letter-spacing: 0.005em;
  text-transform: uppercase;
}

.wordmark span { display: block; }

.masthead-stats {
  display: none;
  margin: 0;
  grid-auto-flow: column;
  gap: 0;
  border-left: 3px solid var(--ink);
}

.masthead-stats > div {
  padding: 2px 18px 6px;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.masthead-stats dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.masthead-stats dd {
  margin: 0;
  font-family: var(--poster);
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
}

.standfirst {
  margin: 18px 0 22px;
  max-width: 62ch;
  font-size: clamp(16px, 1.5vw, 19px);
  line-height: 1.6;
  color: var(--ink);
}

.standfirst em { font-style: italic; }

.masthead::after {
  content: "";
  display: block;
  max-width: 1240px;
  margin: 0 auto;
  border-top: 4px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  height: 3px;
}

/* ---------- Controls (the index-card band) ---------- */

.controls {
  padding: 16px 20px 14px;
}

.controls-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.field-block { display: flex; flex-direction: column; gap: 5px; }

.field-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-bright);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  box-shadow: 3px 3px 0 rgba(33, 28, 20, 0.10);
}

.field::placeholder { color: #8a7f68; }

.field:focus-visible {
  outline-offset: 0;
  box-shadow: 3px 3px 0 var(--accent);
}

.select-wrap { position: relative; display: block; }

.select-wrap::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  width: 8px;
  height: 8px;
  border: solid var(--ink);
  border-width: 0 2.5px 2.5px 0;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

select.field {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  cursor: pointer;
}

.results-line {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-top: 1px dotted var(--rule);
  padding-top: 10px;
}

.results-line b { color: var(--ink); }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper-bright);
  border: 1.5px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(33, 28, 20, 0.10);
  transition: background-color 120ms ease, color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.btn:hover { background: var(--ink); color: var(--paper-bright); }

.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 rgba(0,0,0,0); }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: var(--paper-bright);
}
.btn-accent:hover { background: var(--ink); border-color: var(--ink); color: var(--paper-bright); }

.btn-toggle .toggle-check { display: none; }

.btn-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper-bright);
}

.btn-toggle[aria-pressed="true"] .toggle-check { display: inline; color: var(--accent); }
.btn-toggle[aria-pressed="true"] .toggle-count { color: var(--paper-bright); }

.toggle-count {
  min-width: 1.6em;
  padding: 1px 5px;
  border: 1px solid currentColor;
  font-size: 11px;
}

/* ---------- The listing (ruled programme rows) ---------- */

.listing { max-width: 1240px; margin: 0 auto; padding: 0 20px 30px; }

.day { margin-bottom: 42px; }
.day:last-child { margin-bottom: 10px; }

.day-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--ink);
  margin-bottom: 0;
}

.day-no {
  margin: 0;
  font-family: var(--poster);
  font-weight: 700;
  font-size: 44px;
  line-height: 1;
  color: var(--ink);
  -webkit-text-stroke: 1.4px var(--ink);
  color: transparent;
}

@supports not (-webkit-text-stroke: 1px black) {
  .day-no { color: var(--ink); }
}

.day-title h2 {
  margin: 0;
  font-family: var(--poster);
  font-weight: 700;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.day-sub {
  margin: 3px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.rows { list-style: none; margin: 0; padding: 0; }

.row-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "time lead"
    "main main"
    "side side";
  gap: 4px 14px;
  width: 100%;
  padding: 16px 14px 15px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background-color 120ms ease;
}

.row-btn:focus-visible { outline-offset: -4px; }

.row-btn:hover { background: var(--paper-deep); }

.row.is-saved { background: var(--paper-bright); box-shadow: inset 3px 0 0 var(--accent); }

.row-time {
  grid-area: time;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--ink);
}

.row-time i {
  display: block;
  font-style: normal;
  font-weight: 400;
  color: var(--ink-soft);
}

.row-lead {
  grid-area: lead;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--ink);
}

.glyph {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.row-no {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.row-main { grid-area: main; display: flex; flex-direction: column; gap: 3px; }

.row-title {
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
}

.row-btn:hover .row-title { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2.5px; text-underline-offset: 4px; }

.row-summary {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 72ch;
}

.row-tags {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.row-tags b { color: var(--accent); font-weight: 700; }

.row-side {
  grid-area: side;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.row-venue {
  font-size: 13px;
  font-style: italic;
  color: var(--ink-soft);
}

.row-venue::before { content: "at "; }

.row-price {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}

.row-price.is-free {
  color: var(--accent);
}
.row-price.is-free::before { content: "●"; font-size: 8px; vertical-align: 2px; margin-right: 4px; }

.row-badge {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  padding: 2px 7px 1px;
  transform: rotate(-2deg);
}

/* ---------- Empty state ---------- */

.empty {
  max-width: 560px;
  margin: 40px auto 70px;
  padding: 40px 26px 36px;
  text-align: center;
  border: 2px dashed var(--ink);
  background: var(--paper-bright);
}

.empty-glyph {
  margin: 0 0 6px;
  font-family: var(--poster);
  font-size: 44px;
  line-height: 1;
  color: var(--accent);
}

.empty-title {
  margin: 0 0 8px;
  font-family: var(--poster);
  font-weight: 700;
  font-size: 26px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.empty-text { margin: 0 0 22px; color: var(--ink-soft); }

/* ---------- Colophon ---------- */

.colophon {
  border-top: 4px solid var(--ink);
  margin-top: 30px;
  padding: 22px 20px 34px;
}

.colophon-inner { max-width: 1240px; margin: 0 auto; }

.colophon-brand {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.colophon-fine { margin: 0; font-size: 13px; color: var(--ink-soft); max-width: 78ch; }

.noscript { padding: 30px 20px; text-align: center; color: var(--ink-soft); }

/* ---------- Overlay & ticket ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px 14px;
}

.overlay-scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  animation: scrim-in 180ms ease-out;
}

@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }

.ticket {
  position: relative;
  width: min(680px, 100%);
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-columns: 1fr;
  background: var(--paper-bright);
  border: 2px solid var(--ink);
  box-shadow: var(--hard-shadow);
  animation: ticket-in 220ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes ticket-in {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.ticket-scroll { overflow-y: auto; min-height: 0; padding: 20px 22px 26px; }

.ticket-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 4px double var(--ink);
  margin-bottom: 16px;
}

.ticket-stamp {
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.btn-close {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 11px;
  box-shadow: 2px 2px 0 rgba(33, 28, 20, 0.10);
}

.ticket-title {
  margin: 0 0 12px;
  font-size: clamp(26px, 5.4vw, 36px);
  line-height: 1.12;
  font-weight: 700;
  max-width: 22ch;
}

.ticket-body { max-width: 66ch; }

.ticket-body p { margin: 0 0 14px; font-size: 16.5px; line-height: 1.62; }

.ticket-body p + p {
  padding-top: 14px;
  border-top: 1px dotted var(--rule);
  font-size: 15px;
  color: var(--ink-soft);
}

.ticket-facts {
  margin: 8px 0 20px;
  border-top: 3px solid var(--ink);
}

.ticket-facts > div {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 9px 2px;
  border-bottom: 1px dotted var(--rule);
}

.ticket-facts dt {
  flex: 0 0 118px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.ticket-facts dd { margin: 0; font-size: 15.5px; }

.ticket-facts .fact-price { font-family: var(--mono); font-weight: 700; }
.ticket-facts .fact-price.is-free { color: var(--accent); }

.btn-save { width: 100%; min-height: 54px; font-size: 13.5px; }

.btn-save[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: var(--paper-bright);
}

.btn-save[aria-pressed="true"]:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn-save .save-check { display: none; font-size: 15px; }
.btn-save[aria-pressed="true"] .save-check { display: inline; }

.ticket-foot {
  margin: 14px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
}

.ticket-plan-stamp {
  position: absolute;
  top: 74px;
  right: 20px;
  display: none;
  padding: 6px 11px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  border: 3px double var(--accent);
  background: var(--paper-bright);
  transform: rotate(4deg);
}

.ticket[data-saved="true"] .ticket-plan-stamp { display: block; }

/* Punched stub on wider screens */
.ticket-stub { display: none; }

/* ---------- Desktop ---------- */

@media (min-width: 720px) {

  .masthead { padding-top: 26px; }
  .controls { padding-top: 22px; }

  .controls {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--paper);
    border-bottom: 2px solid var(--ink);
  }

  .controls-inner {
    grid-template-columns: minmax(280px, 1fr) 230px auto;
    align-items: end;
  }

  .field-block-toggle { justify-self: end; }

  .results-line { padding-top: 12px; }

  .masthead-row { grid-template-columns: 1fr auto; }
  .masthead-stats { display: grid; }

  .day-head { padding-bottom: 12px; }
  .day-no { font-size: 58px; }

  .row-btn {
    grid-template-columns: 92px 54px 1fr 210px;
    grid-template-areas: "time lead main side";
    align-items: center;
    gap: 6px 18px;
    padding: 17px 14px;
  }

  .row-lead { justify-content: flex-start; flex-direction: column; gap: 5px; }

  .row-title { font-size: 22px; }

  .row-side {
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
  }

  .row-venue { order: 1; }
  .row-badge { order: 2; }
  .row-price { order: 3; font-size: 15px; }

  .overlay { padding: 30px 24px; }
  .ticket { max-height: min(78vh, 820px); grid-template-columns: 62px 1fr; }
  .ticket-scroll { padding: 26px 30px 30px; }

  .ticket-stub {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    margin: 0;
    padding: 24px 0;
    border-right: 2px dashed rgba(33, 28, 20, 0.35);
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-soft);
    writing-mode: vertical-rl;
  }

  .ticket-stub .glyph { width: 30px; height: 30px; stroke-width: 1.4; color: var(--accent); }

  .ticket::before,
  .ticket::after {
    content: "";
    position: absolute;
    left: 62px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #57503f;
    transform: translateX(-50%);
  }
  .ticket::before { top: -11px; }
  .ticket::after { bottom: -11px; }

  .ticket-plan-stamp { top: 88px; right: 30px; }
}

/* ---------- Motion & print ---------- */

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

@media print {
  .controls, .overlay, .colophon-fine { display: none !important; }
}
