/* Weekend Ledger: a printed weekend listings sheet.
   Signature: a ruled timetable with large start times and ticket-stub rules. */

:root {
  --canvas: #f4efe4;
  --surface: #fffdf7;
  --ink: #1d1b16;
  --ink-muted: #5a554a;
  --rule: #cfc6b2;
  --accent: #b8431f;
  --accent-ink: #fffdf7;
  --focus: #1f5fa8;
  --saved: #2e6b3f;

  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --gutter: clamp(20px, 4vw, 48px);
  --max: 1200px;
  --radius: 2px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 17px/1.55 var(--font-body);
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--ink);
  color: var(--surface);
  padding: 8px 12px;
  z-index: 10;
}

.skip-link:focus {
  top: 12px;
}

.wrap {
  width: min(100% - var(--gutter) * 2, var(--max));
  margin-inline: auto;
}

/* Masthead */

.masthead {
  border-bottom: 3px double var(--ink);
  padding: 28px 0 20px;
}

.masthead__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 4.25rem);
  line-height: 0.95;
  margin: 0;
  letter-spacing: -0.01em;
}

.brand em {
  color: var(--accent);
  font-style: italic;
}

.dateline {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0;
}

.saved-count {
  margin: 0;
  font-size: 0.95rem;
}

.saved-count strong {
  font-variant-numeric: tabular-nums;
}

/* Controls */

.controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: end;
  padding: 24px 0 20px;
  border-bottom: 1px solid var(--rule);
}

.field {
  display: grid;
  gap: 6px;
}

.field__label {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
}

.toggle {
  min-height: 48px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.toggle::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  flex: none;
}

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

.toggle[aria-pressed="true"]::before {
  background: var(--accent);
  border-color: var(--accent);
}

.results-line {
  margin: 14px 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}

/* Timetable list */

.timetable {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.item {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 8px 24px;
  align-items: start;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule);
}

.item__time {
  font-family: var(--font-display);
  font-size: 1.9rem;
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
  padding-top: 4px;
}

.item__time small {
  display: block;
  font: 500 0.75rem/1.2 var(--font-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 6px;
}

.item__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  line-height: 1.2;
  margin: 0 0 6px;
  font-weight: 400;
}

.item__meta {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

.item__summary {
  margin: 8px 0 0;
  max-width: 62ch;
}

.item__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  padding: 2px 8px;
  border-radius: var(--radius);
  color: var(--ink-muted);
}

.tag--saved {
  color: var(--saved);
}

.btn {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
}

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

.btn--ghost:hover {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--ink);
}

/* Empty state */

.empty {
  padding: 56px 0;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}

.empty h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.6rem;
  margin: 0 0 8px;
}

.empty p {
  margin: 0 0 16px;
  color: var(--ink-muted);
}

/* Detail dialog */

.detail {
  border: 0;
  padding: 0;
  margin: auto;
  width: min(100% - 32px, 760px);
  max-height: calc(100dvh - 32px);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgb(29 27 22 / 0.28);
}

.detail::backdrop {
  background: rgb(29 27 22 / 0.5);
}

.detail__inner {
  padding: 28px clamp(20px, 4vw, 40px) 32px;
  overflow: auto;
  max-height: calc(100dvh - 32px);
}

.detail__top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  border-bottom: 3px double var(--ink);
  padding-bottom: 16px;
}

.detail__kicker {
  margin: 0 0 8px;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.detail h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  line-height: 1.15;
  margin: 0;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 20px 0;
  border-top: 1px solid var(--rule);
}

.facts div {
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}

.facts dt {
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.facts dd {
  margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
}

.detail__body {
  white-space: pre-line;
  margin: 0 0 16px;
  max-width: 62ch;
}

.detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--rule);
  padding-top: 20px;
}

.detail__actions .btn[aria-pressed="true"] {
  background: var(--saved);
  border-color: var(--saved);
}

/* Narrow screens */

@media (max-width: 720px) {
  body {
    font-size: 16px;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .field--search {
    grid-column: 1 / -1;
  }

  .item {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .item__time {
    font-size: 1.5rem;
  }

  .item__actions {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding-top: 6px;
  }

  .facts {
    grid-template-columns: 1fr;
  }

  .detail__top {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
