/* ============================================================
   Docket, a weekend agenda
   Type: Oswald (display) + IBM Plex Mono (data) + DM Sans (prose)
   Geometry: all sharp corners (radius 0, one shape system)
   Accent: one amber, locked across light and dark themes
   ============================================================ */

@font-face {
  font-family: 'Oswald';
  src: url('assets/oswald.ttf') format('truetype');
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('assets/dm-sans.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  color-scheme: light dark;
  --font-display: 'Oswald', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Day board (light) */
  --page: #f0f0ec;
  --surface: #fbfbf8;
  --ink: #1b1c1f;
  --ink-2: #565a61;
  --ink-3: #6e7278;
  --line: #d9d9d1;
  --line-strong: #b4b4ab;
  --accent: #e8a41c;
  --accent-strong: #8a5c00;
  --on-accent: #171307;
  --focus: #8a5c00;
  --backdrop: rgba(23, 24, 26, 0.55);
}
@media (prefers-color-scheme: dark) {
  :root {
    /* Night board (dark) */
    --page: #131417;
    --surface: #1b1d21;
    --ink: #eceef0;
    --ink-2: #a2a7ae;
    --ink-3: #82878e;
    --line: #2b2e34;
    --line-strong: #46494f;
    --accent: #f0a828;
    --accent-strong: #f5b949;
    --on-accent: #151004;
    --focus: #f5b949;
    --backdrop: rgba(0, 0, 0, 0.62);
  }
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; margin: 0; }
h1, h2, h3, p, dl, dd, dt, figure { margin: 0; }

.mono { font-family: var(--font-mono); }

.wrap {
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 40px);
}

[hidden] { display: none !important; }

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

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

.icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -56px;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; }

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

.masthead { border-bottom: 1px solid var(--line); }

.masthead-grid {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 40px;
}

.masthead-copy { padding-block: 34px 30px; }

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(58px, 7vw, 96px);
  line-height: 0.92;
  text-transform: uppercase;
  letter-spacing: 0.005em;
  display: flex;
  align-items: baseline;
  gap: 0.09em;
  margin-bottom: 16px;
}

.brand-dot {
  width: 0.13em;
  height: 0.13em;
  background: var(--accent);
  display: inline-block;
  align-self: flex-end;
  margin-bottom: 0.1em;
}

.tagline {
  font-size: 17px;
  color: var(--ink-2);
  max-width: 46ch;
  margin-bottom: 10px;
}

.dateline {
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-2);
}

.masthead-photo {
  position: relative;
  margin: 0;
  width: min(320px, 28%);
  overflow: hidden;
  border-left: 1px solid var(--line);
  flex: none;
}
.masthead-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  filter: grayscale(1) contrast(1.08);
}
.masthead-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  mix-blend-mode: multiply;
  opacity: 0.88;
  pointer-events: none;
}

/* ---------- Control rail ---------- */

.rail {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--page);
  border-bottom: 1px solid var(--line);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 22px;
  padding-block: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

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

.field-search { flex: 1 1 240px; max-width: 380px; }
.field-search .input { width: 100%; }

.input {
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 10px 12px;
}
.input::placeholder { color: var(--ink-2); opacity: 1; }

.select-wrap { position: relative; }
.select {
  appearance: none;
  padding-right: 34px;
  cursor: pointer;
}
.select-chevron {
  position: absolute;
  right: 12px;
  bottom: 13px;
  width: 11px;
  height: 11px;
  pointer-events: none;
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 10px 14px;
  cursor: pointer;
}
.toggle:hover { border-color: var(--ink-2); }
.toggle:active { transform: translateY(1px); }
.toggle.is-on {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.toggle-count {
  font-size: 12px;
  color: var(--ink-2);
}
.toggle.is-on .toggle-count { color: inherit; }

.count {
  margin-left: auto;
  margin-bottom: 11px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-2);
  text-align: right;
}

/* ---------- Board: day columns ---------- */

.main { padding-top: 6px; padding-bottom: 72px; min-height: 55vh; }

.board {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.day { min-width: 0; }
.day:first-child { padding-right: 28px; }
.day + .day {
  border-left: 1px solid var(--line);
  padding-left: 28px;
}

.day-head {
  padding: 28px 4px 16px;
  border-bottom: 2px solid var(--ink);
}
.day-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(26px, 2.6vw, 34px);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  display: flex;
  align-items: baseline;
  gap: 0.18em;
}
.day-num { color: var(--accent-strong); }
.day-date {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  margin-top: 7px;
}

/* ---------- Board: event tiles ---------- */

.tile {
  position: relative;
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 4px 18px;
  padding: 18px 10px 18px 15px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.tile::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: -1px;
  width: 3px;
  background: transparent;
}
.tile:hover { background: var(--surface); }
.tile:hover::before,
.tile:focus-within::before { background: var(--accent); }
.tile.is-saved::before { background: var(--accent); }

.tile-when {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 4px;
}
.tile-start { font-size: 14.5px; color: var(--ink); }
.tile-end { font-size: 11.5px; color: var(--ink-2); }

.tile-title { line-height: 1.18; }

.open-item {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 19px;
  line-height: 1.18;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-align: left;
  color: inherit;
  cursor: pointer;
  padding: 1px 0;
}
.open-item:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

.tile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 7px;
  font-size: 12px;
  color: var(--ink-2);
}
.tile-venue { letter-spacing: 0.01em; }

.tile-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  padding-top: 4px;
}

.chip {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.5;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  padding: 3px 8px;
  white-space: nowrap;
}
.chip-price { color: var(--ink); border-color: var(--ink-3); }
.chip-saved {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.chip-saved .icon { width: 10px; height: 10px; }

.day-empty {
  padding: 24px 15px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}

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

.empty {
  margin-top: 20px;
  padding: 88px 24px;
  border: 1px solid var(--line);
  text-align: center;
}
.empty-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 34px;
  line-height: 1.1;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.empty-body {
  color: var(--ink-2);
  margin-bottom: 26px;
}

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--font-mono);
  font-size: 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 12px 18px;
  cursor: pointer;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }

.btn-solid {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-solid:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--page);
}

/* ---------- Detail dialog ---------- */

.detail {
  width: min(640px, calc(100vw - 28px));
  max-height: min(86dvh, 900px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  display: none; /* [open] restores flex; never leave a closed dialog visible */
  flex-direction: column;
  overflow: hidden;
}
.detail[open] { display: flex; }
.detail::backdrop { background: var(--backdrop); }

.detail-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  cursor: pointer;
}
.detail-close:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.detail-scroll {
  overflow-y: auto;
  padding: 30px 34px 26px;
}

.detail-when {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  margin: 0 46px 12px 0;
}

.detail-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.05;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  margin: 0 46px 14px 0;
}

.detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.detail-lead {
  font-size: 17px;
  line-height: 1.65;
  margin-bottom: 14px;
}

.detail-note {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  max-width: 60ch;
  margin-bottom: 4px;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 22px;
  padding: 16px 0 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.fact dt {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-2);
  margin-bottom: 3px;
}
.fact dd { font-size: 14px; line-height: 1.45; }

.detail-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 34px;
  border-top: 1px solid var(--line);
}

.btn-save {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13.5px;
  padding: 13px 18px;
}
.btn-save .icon { width: 15px; height: 15px; }
.btn-save.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-save.is-on:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--page);
}

/* ---------- Footer ---------- */

.footer { border-top: 1px solid var(--line); }
.footer .wrap { padding-block: 26px 36px; }
.footer p {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}

/* ---------- Motion (all gated behind no-preference) ---------- */

@media (prefers-reduced-motion: no-preference) {
  .tile, .toggle, .btn, .open-item, .detail-close {
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
  }

  .masthead-copy > *,
  .masthead-photo {
    animation: rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  .masthead-copy > :nth-child(2) { animation-delay: 0.08s; }
  .masthead-copy > :nth-child(3) { animation-delay: 0.16s; }
  .masthead-photo { animation-delay: 0.1s; }

  .tile.enter {
    animation: tile-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
    animation-delay: calc(var(--i, 0) * 50ms);
  }

  .detail[open] { animation: dialog-in 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
  .detail[open]::backdrop { animation: fade-in 0.3s ease both; }

  @keyframes rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: none; }
  }
  @keyframes tile-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
  }
  @keyframes dialog-in {
    from { opacity: 0; transform: translateY(14px) scale(0.99); }
  }
  @keyframes fade-in {
    from { opacity: 0; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .toggle:active,
  .btn:active { transform: none; }
}

/* ---------- Mobile ---------- */

@media (max-width: 900px) {
  .masthead-grid { flex-direction: column; gap: 0; }
  .masthead-copy { padding-block: 28px 24px; }
  .brand { font-size: clamp(56px, 16vw, 92px); }
  .masthead-photo {
    width: 100%;
    height: 150px;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  .masthead-photo img { object-position: center 35%; }

  .field-search { flex: 1 1 100%; max-width: none; }
  .count { margin-left: 0; width: 100%; text-align: left; margin-bottom: 0; padding-bottom: 10px; }

  .board { grid-template-columns: 1fr; }
  .day:first-child { padding-right: 0; }
  .day + .day {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--line);
  }

  .tile { grid-template-columns: 1fr; padding: 16px 10px 16px 15px; }
  .tile-when { flex-direction: row; gap: 8px; padding-top: 0; align-items: baseline; }
  .tile-side { flex-direction: row; padding-top: 2px; flex-wrap: wrap; }

  .detail { width: calc(100vw - 24px); max-height: 88dvh; }
  .detail-scroll { padding: 22px 22px 20px; }
  .detail-foot { padding: 14px 22px; }
  .detail-close { top: 10px; right: 10px; }
}

@media (max-width: 480px) {
  .tile-side { flex-direction: column; align-items: flex-start; }
  .open-item { font-size: 18px; }
}
