/* ============================================================================
   Encore design system
   Aubergine / Plum surfaces · Ticket-paper stubs · Marquee amber + Electric
   magenta accents · Lavender secondary. Bricolage Grotesque / Inter / JetBrains
   Mono. Contrast checked to WCAG AA (see the palette table in the README).
   ============================================================================ */

:root {
    --aubergine: #241021;
    --plum: #3a1d3d;
    --plum-2: #4a2851;
    --paper: #f7efe1;
    --amber: #f2a93b;
    --magenta: #ec3f8f;
    --magenta-hi: #f2589f;
    --lavender: #c9b8e8;
    --ink: #241021; /* dark ink for text/QR on ticket paper */

    --text: #f7efe1; /* primary text on dark (15.7:1) */
    --text-muted: #c9b8e8; /* lavender secondary (9.8:1) */
    --line: rgba(201, 184, 232, 0.16);
    --line-strong: rgba(201, 184, 232, 0.34);

    --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
    --focus: #f2a93b; /* amber focus ring — high contrast on dark and on magenta */
    --maxw: 1140px;
}

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

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    color: var(--text);
    background-color: var(--aubergine);
    background-image:
        radial-gradient(1200px 620px at 82% -12%, rgba(236, 63, 143, 0.12), transparent 60%),
        radial-gradient(950px 520px at -12% 8%, rgba(242, 169, 59, 0.09), transparent 55%);
    background-attachment: fixed;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.015em;
    margin: 0 0 0.5em;
    color: var(--paper);
}

h1 { font-size: clamp(1.8rem, 1.2rem + 2.4vw, 2.7rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em; }

a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.display-xl { font-family: var(--font-display); font-weight: 800; font-size: clamp(3.5rem, 2rem + 8vw, 6rem); line-height: 1; }

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.container.narrow { max-width: 560px; }
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.app-main { flex: 1; padding: 28px 0 64px; }
.app-footer { border-top: 1px solid var(--line); padding: 22px 0; color: var(--text-muted); font-size: 0.85rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 8px 0 18px; flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---------- Nav ---------- */
.nav { position: sticky; top: 0; z-index: 50; background: rgba(36, 16, 33, 0.82); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.nav-inner { max-width: var(--maxw); margin: 0 auto; padding: 13px 24px; display: flex; align-items: center; gap: 18px; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; color: var(--paper); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand .dot { color: var(--magenta); margin-left: 1px; }
.nav-links { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.nav-link { color: var(--text-muted); padding: 8px 12px; border-radius: 9px; font-weight: 500; font-size: 0.94rem; }
.nav-link:hover { color: var(--paper); background: var(--plum); text-decoration: none; }
.nav-link.active { color: var(--paper); background: var(--plum); }
.nav-user { color: var(--text-muted); font-size: 0.9rem; padding: 0 6px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--font-body); font-weight: 600; font-size: 0.95rem;
    padding: 11px 18px; border-radius: 11px; border: 1px solid transparent;
    cursor: pointer; transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--magenta); color: var(--ink); } /* dark ink on magenta — AA (4.85:1) */
.btn-primary:hover:not(:disabled) { background: var(--magenta-hi); box-shadow: 0 8px 22px rgba(236, 63, 143, 0.36); }
.btn-amber { background: var(--amber); color: var(--ink); }
.btn-amber:hover:not(:disabled) { background: #f6b957; box-shadow: 0 8px 22px rgba(242, 169, 59, 0.32); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--plum); border-color: var(--lavender); }
.btn-sm { padding: 7px 13px; font-size: 0.88rem; border-radius: 9px; }
.btn-block { width: 100%; }

/* ---------- Surfaces ---------- */
.card { background: var(--plum); border: 1px solid var(--line); border-radius: var(--radius); }
.panel { background: var(--plum); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.panel-pad { padding: 20px; }

/* ---------- Pills & meta ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.05em; }
.pill-amber { background: rgba(242, 169, 59, 0.16); color: var(--amber); }
.pill-magenta { background: rgba(236, 63, 143, 0.18); color: var(--magenta-hi); }
.pill-lavender { background: rgba(201, 184, 232, 0.14); color: var(--lavender); }
.pill-low { background: rgba(236, 63, 143, 0.2); color: var(--magenta-hi); }
.pill-out { background: rgba(201, 184, 232, 0.12); color: var(--text-muted); }
.price { font-family: var(--font-mono); font-weight: 600; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 16px; }
.label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.02em; }
.input, .select, .textarea {
    width: 100%; background: var(--aubergine); color: var(--paper);
    border: 1px solid var(--line-strong); border-radius: 10px; padding: 11px 13px;
    font-family: var(--font-body); font-size: 0.95rem; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { resize: vertical; min-height: 92px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--magenta); box-shadow: 0 0 0 3px rgba(236, 63, 143, 0.25); }
.input::placeholder, .textarea::placeholder { color: rgba(201, 184, 232, 0.5); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.validation-message, .field-error { color: var(--magenta-hi); font-size: 0.82rem; margin-top: 4px; }

/* ---------- Alerts ---------- */
.alert { border-radius: 11px; padding: 12px 15px; font-size: 0.92rem; border: 1px solid transparent; }
.alert-error { background: rgba(236, 63, 143, 0.12); border-color: rgba(236, 63, 143, 0.4); color: #f8a9cd; }
.alert-info { background: rgba(201, 184, 232, 0.1); border-color: var(--line-strong); color: var(--text-muted); }

/* ---------- Event grid & cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.event-card { display: flex; flex-direction: column; overflow: hidden; text-decoration: none; color: inherit; transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease; }
.event-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow); text-decoration: none; }
.event-card .thumb { height: 132px; display: flex; align-items: flex-end; padding: 12px; background-size: cover; background-position: center; position: relative; }
.event-card .thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent, rgba(36, 16, 33, 0.55)); }
.event-card .thumb .pill { position: relative; z-index: 1; }
.event-card .body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.event-card .title { font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; color: var(--paper); line-height: 1.2; }
.event-card .meta { color: var(--text-muted); font-size: 0.88rem; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.event-card .foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-top: 6px; }

/* ---------- Hero (marquee) ---------- */
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 46px 34px; margin-bottom: 30px; border: 1px solid var(--line); background: linear-gradient(120deg, #3a1d3d 0%, #2a1330 55%, #241021 100%); }
.hero h1 { font-size: clamp(2rem, 1.3rem + 3.4vw, 3.4rem); max-width: 16ch; }
.hero p { color: var(--text-muted); max-width: 52ch; font-size: 1.05rem; }
.hero .marquee { position: absolute; inset: 0; pointer-events: none; opacity: 0.5; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; }
.filters .input, .filters .select { width: auto; }
.filters .search { flex: 1; min-width: 220px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--plum); border: 1px solid var(--line); color: var(--text-muted); padding: 6px 13px; border-radius: 999px; font-size: 0.86rem; font-weight: 500; cursor: pointer; transition: all 0.13s ease; }
.chip:hover { border-color: var(--lavender); color: var(--paper); }
.chip.active { background: var(--amber); border-color: var(--amber); color: var(--ink); }

/* ---------- Availability meter ---------- */
.meter { height: 7px; border-radius: 999px; background: rgba(201, 184, 232, 0.16); overflow: hidden; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--magenta)); border-radius: 999px; }

/* ---------- Stats (dashboard) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat { padding: 18px 20px; }
.stat .k { color: var(--text-muted); font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .v { font-family: var(--font-mono); font-weight: 600; font-size: 1.9rem; color: var(--paper); margin-top: 4px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; min-width: 560px; }
table.data th { text-align: left; padding: 12px 16px; color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--line); background: var(--plum); }
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--line); }
table.data tr:last-child td { border-bottom: none; }

/* ---------- Ticket stub (signature; tear animation added in the .torn/keyframes below) ---------- */
.stub { --notch: 15px; position: relative; display: flex; background: var(--paper); color: var(--ink); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; max-width: 460px; }
.stub .main { flex: 1; padding: 22px 24px; min-width: 0; }
.stub .kicker { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: #7a5c46; }
.stub .event { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; line-height: 1.1; margin: 6px 0 12px; color: var(--ink); }
.stub .detail { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.9rem; color: #4a3a2f; }
.stub .detail b { color: var(--ink); }
.stub .code { font-family: var(--font-mono); font-weight: 600; letter-spacing: 0.06em; margin-top: 14px; color: var(--ink); }
.stub .perf { flex: 0 0 128px; position: relative; padding: 18px 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border-left: 2px dashed rgba(36, 16, 33, 0.32); }
/* punch notches top & bottom of the perforation */
.stub .perf::before, .stub .perf::after { content: ""; position: absolute; left: -11px; width: 22px; height: 22px; border-radius: 50%; background: var(--aubergine); }
.stub .perf::before { top: -11px; }
.stub .perf::after { bottom: -11px; }
.stub .qr { width: 92px; height: 92px; }
.stub .qr svg { width: 100%; height: 100%; display: block; }
.stub .scan { font-size: 0.68rem; color: #7a5c46; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- Loading & error UI ---------- */
.app-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: var(--aubergine); }
.app-loading-mark { font-family: var(--font-display); font-weight: 800; font-size: 2rem; color: var(--paper); letter-spacing: -0.02em; }
.app-loading-mark span { color: var(--magenta); margin-left: 2px; }
.app-loading-bar { width: 180px; height: 5px; border-radius: 999px; background: rgba(201, 184, 232, 0.18); overflow: hidden; }
.app-loading-bar span { display: block; width: 40%; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--amber), var(--magenta)); animation: loadslide 1.1s ease-in-out infinite; }
@keyframes loadslide { 0% { transform: translateX(-120%); } 100% { transform: translateX(320%); } }

#blazor-error-ui { color-scheme: dark only; background: #3a1d3d; color: var(--paper); border-top: 1px solid var(--magenta); bottom: 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.4); box-sizing: border-box; display: none; left: 0; padding: 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .reload { color: var(--amber); }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.9rem; top: 0.6rem; }
.blazor-error-boundary { background: #b32158; padding: 1rem 1.25rem; color: white; border-radius: 10px; }
.blazor-error-boundary::after { content: "Something went wrong in this section."; }

/* ---------- Event detail ---------- */
.event-hero { border-radius: 20px; padding: 40px 30px; margin: 4px 0 24px; position: relative; overflow: hidden; border: 1px solid var(--line); }
.event-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(36, 16, 33, 0.15), rgba(36, 16, 33, 0.72)); }
.event-hero > * { position: relative; z-index: 1; }
.event-hero h1 { margin: 12px 0 8px; max-width: 20ch; }
.event-hero-meta { color: var(--paper); font-weight: 500; opacity: 0.92; }
.event-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 26px; align-items: start; }

/* ticket-type selector */
.tt-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; background: var(--aubergine); border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 13px 15px; cursor: pointer; color: var(--text); font-family: var(--font-body); transition: border-color 0.13s ease, background 0.13s ease; }
.tt-row:hover:not(.out) { border-color: var(--lavender); }
.tt-row.sel { border-color: var(--magenta); background: rgba(236, 63, 143, 0.08); }
.tt-row.out { opacity: 0.5; cursor: not-allowed; }
.tt-name { font-weight: 600; color: var(--paper); }
.tt-edit { display: grid; grid-template-columns: 1fr 92px 92px auto; gap: 10px; align-items: center; }
.tt-edit .input { margin: 0; }

/* ticket stubs */
.stub-list { display: flex; flex-direction: column; align-items: center; gap: 20px; }

/* ---------- Signature motion ---------- */
/* Marquee shimmer — a slow light sweep across the hero. */
.hero .marquee {
    background: linear-gradient(115deg, transparent 32%, rgba(247, 239, 225, 0.10) 46%, rgba(242, 169, 59, 0.16) 50%, rgba(247, 239, 225, 0.10) 54%, transparent 68%);
    background-size: 240% 100%;
    animation: marquee-sweep 6.5s linear infinite;
}
@keyframes marquee-sweep { from { background-position: 130% 0; } to { background-position: -130% 0; } }

/* Ticket tear on purchase — the stub tears into view along its perforation. */
.stub.torn { animation: ticket-tear 0.72s cubic-bezier(0.2, 0.85, 0.3, 1.15) both; animation-delay: calc(var(--i, 0) * 0.14s); }
@keyframes ticket-tear {
    0% { opacity: 0; transform: translateY(-16px) rotate(-1.5deg); clip-path: inset(0 0 100% 0); }
    55% { opacity: 1; clip-path: inset(0 0 0 0); }
    70% { transform: translateY(3px) rotate(0.4deg); }
    100% { opacity: 1; transform: none; clip-path: inset(0 0 0 0); }
}
.stub.torn .perf { animation: perf-glint 0.72s ease-out both; animation-delay: calc(var(--i, 0) * 0.14s); }
@keyframes perf-glint { 0%, 45% { box-shadow: none; } 58% { box-shadow: -3px 0 0 rgba(242, 169, 59, 0.65); } 100% { box-shadow: none; } }

/* Scroll reveal — hidden only when JS is present, so no-JS still shows everything. */
.js-reveal .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s ease, transform 0.5s ease; }
.js-reveal .reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
    .event-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .nav-user { display: none; }
    .hero { padding: 34px 22px; }
    .tt-edit { grid-template-columns: 1fr 70px 70px auto; }
    .stub { flex-direction: column; max-width: 380px; }
    .stub .perf { flex-basis: auto; border-left: none; border-top: 2px dashed rgba(36, 16, 33, 0.32); flex-direction: row; }
    .stub .perf::before { top: 50%; left: -11px; transform: translateY(-50%); }
    .stub .perf::after { bottom: auto; top: 50%; left: auto; right: -11px; transform: translateY(-50%); }
}

/* ---------- Motion: respect reduced-motion everywhere ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    /* Never leave reveal content hidden, and drop the marquee sweep entirely. */
    .js-reveal .reveal { opacity: 1 !important; transform: none !important; }
    .hero .marquee { animation: none !important; background: none !important; }
    .stub.torn, .stub.torn .perf { animation: none !important; }
}
