:root {
  --bg: #fff8e7;
  --surface: #fffdf5;
  --ink: #111111;
  --muted: #4a4640;
  --accent: #ff4911;
  --blue: #2436ff;
  --rule: 3px;
  --shadow-rest: 4px 4px 0 var(--ink);
  --shadow-lift: 8px 8px 0 var(--ink);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --display: "Arial Black", "Arial Bold", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --body: "Avenir Next", "Helvetica Neue", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

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

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: clip;
}

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

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

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

.wrap {
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 24px;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

/* Buttons and controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 20px;
  border: var(--rule) solid var(--ink);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-rest);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease), background-color 200ms var(--ease);
}

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

.btn:active {
  transform: scale(0.97);
  box-shadow: none;
}

.btn:focus-visible,
.field:focus-visible,
.toggle:focus-visible,
.ticket-open:focus-visible,
.save-toggle:focus-visible,
.close-btn:focus-visible,
.nav-btn:focus-visible,
.brand:focus-visible,
.nav-link:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

/* Header */

.site-header {
  padding-block: 16px;
  border-bottom: var(--rule) solid var(--ink);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--display);
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  padding-block: 8px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link,
.nav-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  background: none;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.nav-btn {
  border: var(--rule) solid var(--ink);
  background: var(--surface);
}

.nav-btn:active,
.nav-link:active {
  transform: scale(0.97);
}

/* Hero */

.hero {
  background: var(--ink);
  color: var(--bg);
  padding-block: clamp(64px, 9vw, 128px);
}

.hero-grid {
  display: grid;
  gap: 48px;
  align-items: center;
}

.eyebrow {
  color: var(--bg);
  opacity: 0.85;
  margin-bottom: 24px;
}

.hero h1 {
  font-family: var(--display);
  font-size: clamp(44px, 6.8vw, 100px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
  font-weight: 900;
}

.lede {
  margin-top: 24px;
  max-width: 52ch;
  font-size: 18px;
  line-height: 1.6;
}

.hero-actions {
  margin-top: 32px;
}

.hero-ticket {
  position: relative;
  background: var(--bg);
  color: var(--ink);
  border: var(--rule) solid var(--bg);
  padding: 32px;
  animation: ticket-in 520ms var(--ease) both;
}

.hero-ticket-day {
  font-family: var(--display);
  font-size: clamp(120px, 22vw, 260px);
  line-height: 0.85;
  letter-spacing: -0.04em;
}

.hero-ticket-title {
  margin-top: 16px;
  font-family: var(--display);
  font-size: 28px;
  letter-spacing: -0.01em;
}

.hero-ticket-facts {
  margin-top: 12px;
  color: var(--muted);
}

.stub {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 3px dashed var(--ink);
}

.stub .btn {
  width: 100%;
}

@keyframes ticket-in {
  from {
    opacity: 0;
    transform: translateY(24px) rotate(-2deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Ledger band */

.ledger {
  padding-block: 96px;
}

.section-title {
  font-family: var(--display);
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 900;
  margin-bottom: 32px;
}

.ledger-rows {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: var(--rule) solid var(--ink);
}

.ledger-rows li {
  display: grid;
  grid-template-columns: minmax(0, auto) 1fr;
  gap: 24px;
  align-items: baseline;
  padding-block: 20px;
  border-bottom: var(--rule) solid var(--ink);
}

.ledger-num {
  font-family: var(--display);
  font-size: clamp(56px, 8vw, 104px);
  line-height: 0.9;
  letter-spacing: -0.04em;
}

.ledger-text {
  font-size: 18px;
}

/* Catalogue */

.catalogue {
  padding-block: 64px 128px;
}

.controls {
  display: grid;
  gap: 16px;
  padding-block: 24px;
  border-block: var(--rule) solid var(--ink);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: var(--rule) solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  font-size: 16px;
  color: var(--ink);
}

.control-row {
  display: grid;
  gap: 16px;
  align-items: end;
}

.toggle {
  min-height: 52px;
  padding: 12px 16px;
  border: var(--rule) solid var(--ink);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 200ms var(--ease), color 200ms var(--ease), transform 200ms var(--ease);
}

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

.toggle:active {
  transform: scale(0.97);
}

.count {
  padding-block: 16px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ticket-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 32px;
}

.ticket {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--surface);
  border: var(--rule) solid var(--ink);
  box-shadow: var(--shadow-rest);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
}

.ticket-photo {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-bottom: var(--rule) dashed var(--ink);
}

.ticket-main {
  padding: 24px;
}

.ticket-meta {
  color: var(--muted);
}

.ticket-title {
  margin-top: 8px;
  font-family: var(--display);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.ticket-open {
  position: static;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.ticket-open::after {
  content: "";
  position: absolute;
  inset: 0;
}

.ticket:has(.ticket-open:focus-visible) {
  outline: 3px solid var(--blue);
  outline-offset: 4px;
}

.ticket-summary {
  margin-top: 12px;
  max-width: 60ch;
}

.ticket-facts {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.ticket-stub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-top: var(--rule) dashed var(--ink);
}

.ticket-no {
  font-family: var(--display);
  font-size: 48px;
  line-height: 1;
  letter-spacing: -0.03em;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tag-saved {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.tag-passed {
  background: transparent;
}

.empty-state {
  margin-top: 24px;
  padding: 32px 24px;
  border: 3px dashed var(--ink);
  background: var(--surface);
}

.empty-state h3 {
  font-family: var(--display);
  font-size: 24px;
  line-height: 1.1;
  margin-bottom: 12px;
}

.empty-state p + .btn {
  margin-top: 20px;
}

.empty-state[hidden],
.ticket-list[hidden],
[hidden] {
  display: none !important;
}

/* Closing band */

.closing {
  border-top: var(--rule) solid var(--ink);
  padding-block: 96px;
}

.closing .wrap {
  display: grid;
  gap: 32px;
}

.closing h2 {
  font-family: var(--display);
  font-size: clamp(32px, 5vw, 64px);
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 900;
}

.closing p {
  max-width: 56ch;
  font-size: 18px;
}

.closing .btn {
  justify-self: start;
}

/* Footer */

.site-footer {
  background: var(--ink);
  color: var(--bg);
  padding-block: 32px;
}

.site-footer .wrap {
  display: grid;
  gap: 8px;
}

.site-footer .brand {
  color: var(--bg);
}

/* Detail dialog */

.detail {
  width: min(920px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: var(--rule) solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 12px 12px 0 var(--ink);
  overflow: auto;
}

.detail::backdrop {
  background: rgba(17, 17, 17, 0.72);
}

.detail-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: var(--rule) solid var(--ink);
}

.close-btn {
  min-height: 44px;
  padding: 8px 16px;
  border: var(--rule) solid var(--ink);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 200ms var(--ease);
}

.close-btn:active {
  transform: scale(0.97);
}

.detail-image {
  width: 100%;
  aspect-ratio: 16 / 7;
  object-fit: cover;
  border-bottom: var(--rule) solid var(--ink);
}

.detail-body {
  padding: 32px 24px 40px;
}

.detail-title {
  margin-top: 8px;
  font-family: var(--display);
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
  letter-spacing: -0.03em;
}

.detail-when {
  margin-top: 16px;
  font-size: 18px;
  font-weight: 600;
}

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

.facts > div {
  padding: 12px 0;
  border-bottom: 2px solid var(--ink);
}

.facts dt {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.facts dd {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 600;
}

.detail-text {
  margin-top: 24px;
  max-width: 62ch;
  font-size: 18px;
  line-height: 1.65;
}

.detail-actions {
  margin-top: 32px;
}

.save-toggle {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 12px 24px 12px 12px;
  border: var(--rule) solid var(--ink);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow-rest);
  transition: background-color 200ms var(--ease), color 200ms var(--ease), transform 200ms var(--ease), box-shadow 200ms var(--ease);
}

.save-toggle[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  box-shadow: none;
}

.save-toggle:active {
  transform: scale(0.97);
}

.stub-tab {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 2px dashed currentColor;
  transition: transform 200ms var(--ease), opacity 200ms var(--ease);
}

.save-toggle[aria-pressed="true"] .stub-tab {
  transform: translate(6px, -8px) rotate(-14deg);
  opacity: 0.7;
}

.save-hint {
  margin-top: 12px;
  font-size: 15px;
  color: var(--muted);
}

/* Hover (fine pointers only) */

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--ink);
  }

  .nav-btn:hover,
  .nav-link:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
  }

  .nav-btn:hover {
    background: var(--ink);
    color: var(--bg);
  }

  .ticket:hover {
    transform: translate(-3px, -3px);
    box-shadow: var(--shadow-lift);
  }

  .ticket-open:hover {
    text-decoration: underline;
    text-decoration-thickness: 3px;
    text-underline-offset: 4px;
  }

  .toggle:hover {
    background: var(--ink);
    color: var(--bg);
  }

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

  .field:hover {
    border-color: var(--blue);
  }

  .close-btn:hover {
    background: var(--ink);
    color: var(--bg);
  }

  .save-toggle:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--ink);
  }

  .save-toggle[aria-pressed="true"]:hover {
    box-shadow: none;
    background: var(--accent);
    color: var(--ink);
  }

  .stub:hover .stub-tab {
    transform: translate(2px, -2px);
  }

  .empty-state .btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--ink);
  }
}

/* Layout breakpoints */

@media (min-width: 720px) {
  .control-row {
    grid-template-columns: 1fr auto;
  }

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

  .ticket {
    grid-template-columns: 280px 1fr;
  }

  .ticket-photo {
    align-self: stretch;
    height: auto;
    min-height: 240px;
    aspect-ratio: auto;
    border-bottom: 0;
    border-right: var(--rule) dashed var(--ink);
  }

  .ticket-stub {
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    border-top: 0;
    border-left: var(--rule) dashed var(--ink);
    min-width: 140px;
  }

  .facts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .detail {
    width: min(920px, calc(100% - 48px));
  }

  .detail-image {
    aspect-ratio: 16 / 6;
  }
}

@media (min-width: 900px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  }

  .control-row {
    grid-template-columns: minmax(0, 1fr) 200px 220px;
  }
}

@media (max-width: 719px) {
  .detail {
    width: 100%;
    max-width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .detail-body {
    padding-inline: 20px;
  }
}

/* Reduced motion: keep opacity, drop transform motion */

@media (prefers-reduced-motion: reduce) {
  .hero-ticket {
    animation-name: fade-in;
  }

  .ticket,
  .btn,
  .toggle,
  .save-toggle,
  .close-btn,
  .stub-tab {
    transition-property: opacity, background-color, color;
  }

  .ticket:hover,
  .btn:hover,
  .save-toggle:hover,
  .btn:active,
  .save-toggle:active,
  .toggle:active,
  .nav-btn:active,
  .nav-link:active,
  .close-btn:active {
    transform: none;
  }

  .save-toggle[aria-pressed="true"] .stub-tab {
    transform: none;
  }
}

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