/* Field Day — civic timetable world
   paper: cool blue-gray · ink: blue-black · accent: ultramarine-violet */

@font-face {
  font-family: "Archivo";
  src: url("assets/archivo-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Spline Sans Mono";
  src: url("assets/spline-sans-mono-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #e5eaed;
  --panel: #f5f8f9;
  --ink: #14202b;
  --ink-2: #4a5a66;
  --line: rgba(20, 32, 43, 0.16);
  --line-strong: rgba(20, 32, 43, 0.55);
  --accent: #5b3bd5;
  --accent-deep: #4630a8;
  --shadow: 0 24px 60px rgba(16, 26, 36, 0.35), 0 4px 14px rgba(16, 26, 36, 0.18);
  --radius: 10px;
  --mono: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Archivo", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb {
  background: rgba(20, 32, 43, 0.35);
  border-radius: 8px;
  border: 3px solid var(--paper);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 100;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
  font-weight: 600;
  transition: top 0.15s ease-out;
}
.skip-link:focus { top: 0; }

.shell {
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: 28px;
}

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

.masthead { padding: 44px 0 26px; }

.masthead-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 64px;
  align-items: end;
  padding-bottom: 26px;
  border-bottom: 3px solid var(--ink);
  position: relative;
}
.masthead-grid::after {
  content: "";
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: -7px;
  border-bottom: 1px solid var(--ink);
}

.brand {
  margin: 0 0 10px;
  font-size: clamp(3.2rem, 8vw, 5.8rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.94;
  text-transform: uppercase;
}
.brand::after {
  content: "";
  display: inline-block;
  width: 0.32em;
  height: 0.32em;
  margin-left: 0.12em;
  border-radius: 50%;
  background: var(--accent);
}

.masthead-sub {
  margin: 0;
  max-width: 56ch;
  font-size: 1.05rem;
  color: var(--ink-2);
}
.masthead-sub strong { color: var(--ink); font-weight: 600; }

.masthead-side {
  display: grid;
  gap: 10px;
  justify-items: end;
  padding-bottom: 6px;
}

.mono-meta {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: 340px;
}
.legend li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* category spot colors: vivid dot + dark ink for text */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cat, var(--accent));
  flex: none;
}
.cat-art        { --cat: #5b3bd5; --cat-ink: #4630a8; }
.cat-film       { --cat: #c22f8e; --cat-ink: #9c2371; }
.cat-food       { --cat: #d14423; --cat-ink: #a23114; }
.cat-literature { --cat: #0f7a80; --cat-ink: #0b5f64; }
.cat-music      { --cat: #2451d0; --cat-ink: #1d3fa8; }
.cat-outdoors   { --cat: #3e9450; --cat-ink: #27683a; }
.cat-walks      { --cat: #b08100; --cat-ink: #7d5900; }

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

.toolbar-wrap {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line-strong);
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  padding-block: 14px;
}

.field { display: grid; gap: 5px; }
.field-grow { flex: 1 1 260px; max-width: 400px; }

.field-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-2);
}

.search-box { position: relative; }
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 17px;
  height: 17px;
  translate: 0 -50%;
  color: var(--ink-2);
  pointer-events: none;
}

input[type="search"],
select {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 12px;
  appearance: none;
}
input[type="search"] { padding-left: 37px; }
input[type="search"]::placeholder { color: var(--ink-2); opacity: 1; }
input[type="search"]:focus,
select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

select {
  padding-right: 34px;
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 8"><path d="M1.5 1.5 6 6l4.5-4.5" fill="none" stroke="%2314202B" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  cursor: pointer;
}

.saved-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.15s ease-out, color 0.15s ease-out, border-color 0.15s ease-out;
}
.saved-toggle .icon { width: 16px; height: 16px; }
.saved-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: #fff;
}
.saved-toggle[aria-pressed="true"] .icon path { fill: currentColor; }
.badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 99px;
  background: var(--ink);
  color: var(--paper);
}
.saved-toggle[aria-pressed="true"] .badge { background: #fff; color: var(--accent-deep); }

.toolbar-count {
  margin: 0 0 2px auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-2);
  white-space: nowrap;
}

/* ---------- schedule ---------- */

main { padding: 34px 0 72px; min-height: 52vh; }

.days {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 0;
}

.day { padding-inline: 0 40px; }
.day + .day {
  padding-inline: 40px 0;
  border-left: 1px solid var(--line-strong);
}
.day.solo { grid-column: 1 / -1; padding-inline: 0; }

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 4px;
}
.day-head h2 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
.day-head .day-date {
  font-weight: 500;
  color: var(--ink-2);
  font-size: 1.05rem;
  letter-spacing: 0;
  white-space: nowrap;
}
.day-count {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-2);
  white-space: nowrap;
}

/* timetable line */

.event {
  display: grid;
  grid-template-columns: 112px 1fr auto;
  grid-template-areas: "time main side";
  gap: 6px 18px;
  align-items: start;
  padding: 17px 10px 18px;
  border-bottom: 1px solid var(--line);
  position: relative;
  transition: background 0.15s ease-out;
}
.event:hover, .event:has(.event-open:focus-visible) { background: var(--panel); }

.cell-time {
  grid-area: time;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}
.cell-time time {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  white-space: nowrap;
}

.cell-main { grid-area: main; min-width: 0; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 3px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--cat-ink, var(--ink));
}

.event-title { margin: 0; font-size: 1.13rem; line-height: 1.3; }
.event-open {
  font: inherit;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: text-decoration-color 0.15s ease-out;
}
.event:hover .event-open,
.event-open:focus-visible { text-decoration-color: var(--accent); }
/* stretch the open control over the line, keeping the save button clear */
.event-open::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.event-meta {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--ink-2);
}

.cell-side {
  grid-area: side;
  display: grid;
  justify-items: end;
  gap: 9px;
  padding-top: 3px;
  position: relative;
  z-index: 2;
}

.price {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.price.free { color: #27683a; font-weight: 700; }

.save-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease-out, color 0.15s ease-out, border-color 0.15s ease-out;
}
.save-btn .icon { width: 16px; height: 16px; }
.save-btn:hover { color: var(--ink); background: #fff; }
.save-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: #fff;
}
.save-btn[aria-pressed="true"] .icon path { fill: currentColor; }

/* entrance motion — one authored moment, settled by default */
body.boot .event,
body.boot .day-head {
  animation: rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(min(var(--i, 0), 9) * 45ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
}

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

.empty {
  margin-top: 18px;
  padding: 64px 28px;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
}
.empty h2 { margin: 0 0 8px; font-size: 1.5rem; letter-spacing: -0.02em; }
.empty p { margin: 0 auto 22px; max-width: 44ch; color: var(--ink-2); }

.btn {
  font: inherit;
  font-weight: 650;
  color: #fff;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 11px 20px;
  cursor: pointer;
  transition: background 0.15s ease-out;
}
.btn:hover { background: #223344; }

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

.colophon {
  border-top: 1px solid var(--line-strong);
  padding: 22px 0 34px;
}
.colophon p {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.7;
  color: var(--ink-2);
  max-width: 72ch;
}

/* ---------- detail dialog ---------- */

.detail {
  width: min(680px, calc(100% - 32px));
  max-height: min(86vh, 860px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
}
.detail::backdrop {
  background: rgba(14, 22, 30, 0.55);
  animation: fade 0.2s ease-out;
}
.detail[open] { animation: pop 0.2s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
}
@keyframes fade { from { opacity: 0; } }

.detail-card { padding: 26px 30px 28px; }

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.detail-head .tag { margin: 0; font-size: 0.78rem; }

.close-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s ease-out, color 0.15s ease-out;
}
.close-btn svg { width: 15px; height: 15px; }
.close-btn:hover { background: var(--ink); color: var(--paper); }

.detail-title {
  margin: 0 0 18px;
  font-size: clamp(1.6rem, 4.5vw, 2rem);
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
  margin: 0 0 22px;
  padding: 16px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.facts dt {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-2);
  margin-bottom: 3px;
}
.facts dd { margin: 0; font-size: 0.98rem; font-weight: 550; }

.detail-body { max-width: 62ch; }
.detail-body .lede { font-size: 1.06rem; margin: 0 0 12px; }
.detail-body p { margin: 0 0 12px; color: var(--ink); }
.body-label {
  margin: 18px 0 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-2);
}
.detail-body .access { color: var(--ink-2); }

.detail-foot {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.save-item-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  padding: 13px 18px;
  cursor: pointer;
  transition: background 0.15s ease-out, color 0.15s ease-out, border-color 0.15s ease-out;
}
.save-item-btn .icon { width: 18px; height: 18px; }
.save-item-btn:hover { background: #fff; }
.save-item-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent-deep);
  color: #fff;
}
.save-item-btn[aria-pressed="true"] .icon path { fill: currentColor; }

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

@media (max-width: 920px) {
  .masthead-grid { grid-template-columns: 1fr; align-items: start; }
  .masthead-side { justify-items: start; }
  .legend { justify-content: flex-start; max-width: none; }
  .days { grid-template-columns: 1fr; }
  .day, .day + .day { padding-inline: 0; border-left: 0; }
  .day + .day { margin-top: 44px; }
  .day.solo { margin-top: 0; }
}

@media (max-width: 720px) {
  .shell { padding-inline: 18px; }
  .masthead { padding: 30px 0 20px; }
  .masthead-grid::after { left: 18px; right: 18px; }

  .toolbar { flex-wrap: wrap; gap: 12px 14px; align-items: stretch; }
  .field-grow { flex: 1 1 100%; max-width: none; }
  .field:nth-child(2) { flex: 1 1 auto; min-width: 150px; }
  .saved-toggle { flex: none; }
  .toolbar-count { flex: 1 1 100%; order: 10; margin: 0; }

  .event {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "time time"
      "main main"
      "side side";
    row-gap: 8px;
    padding: 15px 10px 16px;
  }
  .cell-time { padding-top: 0; }
  .cell-side {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0;
  }
}

@media (max-width: 400px) {
  .brand { font-size: clamp(2.7rem, 13vw, 3.2rem); }
  .facts { grid-template-columns: 1fr; gap: 12px; }
  .detail-card { padding: 20px 18px 22px; }
}

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