/* Visual language ported from your100-event-manager-v2 (app/app.css and
   .project/docs/design-system.md): warm off-white ground, navy shell, one orange-red
   brand, DM Sans for text and Geist Mono for times. Light only.
   Fonts are self-hosted copies of the Fontsource 5.3.0 variable files (SIL OFL 1.1,
   licenses beside them in app/assets/fonts). */
@font-face {
  font-family: "DM Sans Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 1000;
  src: url("/assets/dm-sans-latin-wght-normal-fe3ac7ee.woff2") format("woff2-variations");
}

@font-face {
  font-family: "Geist Mono Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("/assets/geist-mono-latin-wght-normal-a600ad3f.woff2") format("woff2-variations");
}

:root {
  --brand: #cc431c; --brand-dark: #7d2610; --brand-tint: #fdf0eb; --brand-tint-border: #f7d5c8;
  --navy: #0b0d58; --navy-active: #1b1f7d; --navy-text: #eceefb; --navy-accent: #ff8a5c; --navy-border: rgb(255 255 255 / .12);
  --bg: #faf6f4; --card: #ffffff; --muted-bg: #f3efec; --ink: #1f1b17; --muted: #5f5850;
  --border: #e8e2dd; --border-strong: #d9d2cc;
  --done-bg: #dcfce7; --done-fg: #14532d; --waiting-bg: #eceefb; --waiting-fg: #0b0d58;
  --warning-bg: #fffbeb; --warning-fg: #92400e; --warning-border: #e0b97a; --overdue: #831c1e;
  --sans: "DM Sans Variable", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono Variable", ui-monospace, monospace;
  color-scheme: light;
  font-family: var(--sans);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: .875rem; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-dark); text-underline-offset: 4px; }
/* A plain link in running text is underlined, so it never relies on colour alone. */
a:not([class]) { text-decoration: underline; }
a[class] { text-decoration: none; }
h1 { font-size: 1.5rem; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 1rem; text-wrap: balance; }
h2 { font-size: 1.125rem; line-height: 1.3; font-weight: 600; margin: 0 0 .75rem; text-wrap: balance; }
p { margin: 0 0 .75rem; }
time, .mono { font-family: var(--mono); font-size: .8125rem; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Shell: sticky 64px navy top bar; 240px navy sidebar for signed-in staff from 768px. */
.site-nav { position: sticky; top: 0; z-index: 30; height: 64px; display: flex; align-items: center; gap: 1rem; padding: 0 1rem; background: var(--navy); color: var(--navy-text); border-bottom: 1px solid var(--navy-border); }
.brand-mark { display: flex; align-items: center; gap: .6rem; min-height: 44px; color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; white-space: nowrap; }
.brand-mark i { width: 10px; height: 26px; border-radius: 3px; background: var(--brand); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; min-width: 0; }
.top-right .who { display: flex; align-items: center; gap: .6rem; font-size: .8125rem; min-width: 0; }
.top-right .who .avatar { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 6px; background: var(--card); color: var(--navy); font-weight: 600; text-transform: uppercase; }
.top-right .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-right .who small { display: block; margin: 0; color: rgb(236 238 251 / .75); font-size: .8125rem; text-transform: capitalize; }
.site-nav form { margin: 0; }
.site-nav .btn, .site-nav button { background: transparent; color: var(--navy-text); border-color: rgb(236 238 251 / .4); }
.site-nav .btn:hover, .site-nav button:hover { background: var(--navy-active); border-color: rgb(236 238 251 / .4); color: #fff; }

.shell { display: flex; min-width: 0; }
.sidebar { width: 240px; flex: none; position: sticky; top: 64px; height: calc(100dvh - 64px); overflow-y: auto; background: var(--navy); color: var(--navy-text); padding: .75rem; }
.sidebar .group { padding: .75rem .75rem .25rem; font-size: .8125rem; color: rgb(236 238 251 / .75); }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a { text-decoration: none; display: flex; align-items: center; min-height: 40px; padding: 0 .75rem; border-radius: 6px; color: var(--navy-text); }
.sidebar nav a:hover { background: rgb(255 255 255 / .1); }
.sidebar nav a.on { background: var(--navy-active); color: #fff; font-weight: 600; box-shadow: inset 2px 0 var(--brand); }

main { flex: 1; min-width: 0; padding: 1rem; }
@media (min-width: 768px) {
  .site-nav { padding: 0 1.5rem; }
  main { padding: 1.25rem; }
}
@media (max-width: 767px) {
  .shell { flex-direction: column; }
  .sidebar { position: static; width: auto; height: auto; padding: .25rem .5rem; }
  .sidebar .group { display: none; }
  .sidebar nav { display: flex; overflow-x: auto; scrollbar-width: none; }
  .sidebar nav a { white-space: nowrap; }
  .top-right .who span, .top-right .who small { display: none; }
}

/* Flash */
.flash { margin: 0 0 1rem; padding: .75rem 1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--card); max-width: 48rem; }
.flash.notice { background: var(--done-bg); color: var(--done-fg); border-color: color-mix(in srgb, var(--done-fg) 25%, transparent); }
.flash.alert { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-border); }

/* Cards: 12px corners, 1px border, minimal shadow. */
.card, article.event, .registration, .rsvp, .invitations, main > form, main > table {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.25rem; margin-bottom: 1rem;
}
main > form, .invitations form { max-width: 40rem; }
article.event, .registration, .rsvp { max-width: 48rem; }
main > table { padding: .25rem .5rem; }
/* Guest-facing sign-in and password pages: one card with a brand top rule. */
.auth main { max-width: 28rem; margin: 0 auto; padding-top: 3rem; }
.auth main > form { border-top: 4px solid var(--brand); padding: 1.5rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: .8125rem; font-weight: 500; color: var(--muted); }
td.actions { display: flex; gap: .75rem; align-items: center; }
.invitations table { margin-bottom: 1.25rem; }

/* Forms: 40px controls (44px with 16px text on phones, so iOS does not zoom). */
form p { margin: 0 0 1rem; }
label { display: block; font-weight: 500; margin: 0 0 .375rem; }
input, select, textarea { font: inherit; font-size: 1rem; color: inherit; background: var(--card); border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 .75rem; min-height: 44px; width: 100%; }
textarea { padding: .6rem .75rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 0; border-color: var(--brand); }
input[readonly] { background: var(--muted-bg); color: var(--muted); }
@media (min-width: 768px) { input, select, textarea { font-size: .875rem; min-height: 40px; } }
small { display: block; color: var(--muted); margin-top: .375rem; font-size: .8125rem; }
.errors { background: var(--card); border: 1px solid var(--overdue); color: var(--overdue); border-radius: 8px; padding: .75rem 1rem; margin: 0 0 1rem; list-style: none; }
.errors p { margin: 0; }
[role=alert] { color: var(--overdue); }
span[role=alert] { display: block; font-size: .8125rem; margin-top: .375rem; }

/* Event form: one card, grouped fieldsets, two columns from 768px, one on phones. */
form.event-form { max-width: 52rem; padding: 0; }
.event-form > .errors { margin: 1.25rem 1.25rem 0; }
.event-form .errors ul { margin: .25rem 0 0; padding-left: 1.25rem; }
.event-form > fieldset { margin: 0; padding: 1.25rem; border: 0; border-bottom: 1px solid var(--border); min-width: 0; }
.event-form > fieldset > legend { padding: 0; margin: 0 0 1rem; font-size: 1rem; font-weight: 600; float: left; width: 100%; }
.event-form > fieldset > legend + * { clear: both; }
.event-form .grid { display: grid; grid-template-columns: 1fr; gap: 1rem 1.25rem; }
.event-form .field { min-width: 0; }
.event-form fieldset.field { margin: 0; padding: 0; border: 0; }
.event-form .label { display: block; font-weight: 500; margin: 0 0 .375rem; padding: 0; }
.event-form .hint-row { margin-top: -.5rem; }
.field-error { color: var(--overdue); font-weight: 500; }
.field-error[hidden] { display: none; }
/* Mark the control and label of any field showing an error, including a type select whose error sits on :event_type. */
.field:has(.field-error:not([hidden])) :is(input, select, textarea) { border-color: var(--overdue); }
.field:has(.field-error:not([hidden])) > label { color: var(--overdue); }
.optional { font-weight: 400; color: var(--muted); font-size: .8125rem; }
.choice-chips { display: grid; grid-template-columns: 1fr; gap: .5rem; }
.choice { display: flex; gap: .75rem; align-items: flex-start; margin: 0; padding: .75rem 1rem; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--card); cursor: pointer; font-weight: 400; }
.choice input { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.choice strong { display: block; font-weight: 600; }
.choice small { margin: .125rem 0 0; }
.choice:has(input:checked) { background: var(--brand-tint); border-color: var(--brand); }
.choice:has(input:checked) strong { color: var(--brand-dark); }
.choice:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 2px; }
.form-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: 1.25rem; }
.form-actions small { margin: 0; }
/* Rails wraps invalid fields in a div; keep the layout intact and mark the control. */
.field_with_errors { display: contents; }
.field_with_errors input, .field_with_errors select, .field_with_errors textarea { border-color: var(--overdue); }
.field_with_errors label { color: var(--overdue); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (min-width: 768px) {
  .event-form .grid { grid-template-columns: 1fr 1fr; }
  .event-form .span-2 { grid-column: 1 / -1; }
  .choice-chips { grid-template-columns: 1fr 1fr; }
}

/* Buttons: 6px corners, 44px on phones, 40px from 768px. */
button, input[type=submit], .btn { font: 500 .875rem var(--sans); display: inline-flex; align-items: center; justify-content: center; gap: .5rem; width: auto; min-height: 44px; padding: 0 .9rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--ink); cursor: pointer; white-space: nowrap; }
@media (min-width: 768px) { button, input[type=submit], .btn { min-height: 40px; } }
button:hover, .btn:hover { background: var(--muted-bg); }
input[type=submit], button.primary, .btn.primary { background: var(--brand); border-color: transparent; color: #fff; }
input[type=submit]:hover, button.primary:hover, .btn.primary:hover { background: color-mix(in srgb, var(--brand) 80%, #fff); }
button.danger { background: color-mix(in srgb, var(--overdue) 10%, transparent); border-color: transparent; color: var(--overdue); }
button.danger:hover { background: color-mix(in srgb, var(--overdue) 20%, transparent); }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.actions form, td.actions form { margin: 0; }
.toolbar { margin-bottom: 1rem; }

/* Public pages */
.event-type { display: inline-flex; align-items: center; min-height: 24px; padding: 0 .6rem; border-radius: 999px; background: var(--brand-tint); border: 1px solid var(--brand-tint-border); color: var(--brand-dark); font-size: .8125rem; font-weight: 500; margin-bottom: .6rem; }
.event-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.event-list .event { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.25rem; }
.event-list .event:hover { border-color: var(--brand-tint-border); }
.event-list .event h2 { margin: 0 0 .5rem; }
.event-list .event h2 a { color: var(--ink); text-decoration: none; }
.event-list .event:hover h2 a { color: var(--brand-dark); }
/* The title link covers the card, so the whole card opens the event. */
.event-list .event h2 a::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
.event-list .event p { color: var(--muted); margin: 0 0 .25rem; }
.sold-out { background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning-fg); border-radius: 8px; padding: .75rem 1rem; max-width: 48rem; font-weight: 600; }
.rsvp .sold-out { margin-bottom: 1rem; }

/* Attendee list / door view */
.door-header h1 { margin-bottom: .25rem; }
.muted { color: var(--muted); }
.headcount { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0 0 1rem; }
.headcount div { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .75rem 1rem; min-width: 8.5rem; }
.headcount dt { color: var(--muted); font-size: .8125rem; }
.headcount dd { margin: 0; font-size: 1.5rem; font-weight: 600; font-family: var(--mono); }
.door-list tbody th { font-size: .875rem; font-weight: 600; color: var(--ink); }
.door-list td { word-break: break-word; }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 0 .6rem; border-radius: 999px; font-size: .8125rem; font-weight: 500; white-space: nowrap; }
.status.done { background: var(--done-bg); color: var(--done-fg); }
.status.waiting { background: var(--waiting-bg); color: var(--waiting-fg); }
.door-list td.door { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.door-list td.door form { margin: 0; }
.door-list tr.checked-in { background: color-mix(in srgb, var(--done-bg) 35%, transparent); }
button.link { min-height: 40px; padding: 0 .25rem; border: 0; background: none; color: var(--brand-dark); text-decoration: underline; text-underline-offset: 4px; }
button.link:hover { background: none; }
.print-only { display: none; }
/* Arrival flash: the row the door list returns to after a check-in. */
.door-list tr:target { outline: 2px solid var(--brand); outline-offset: -2px; }
/* Phones at the door: each attendee is a block, no sideways scrolling. Paper keeps the table. */
@media screen and (max-width: 767px) {
  .door-list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .door-list tr { display: grid; gap: .125rem; padding: .75rem .25rem; border-bottom: 1px solid var(--border); }
  .door-list tr:last-child { border-bottom: 0; }
  .door-list th, .door-list td { display: block; padding: 0; border: 0; }
  .door-list td:last-child { margin-top: .25rem; }
}

@media print {
  .site-nav, .sidebar, .noprint, .flash { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  main > table, .headcount div { border-color: #999; }
  .status { background: none !important; padding: 0; color: #000 !important; }
  tr { break-inside: avoid; }
  .print-only { display: inline; font-size: 1.1rem; }
}
