:root {
  color-scheme: light;
  --background: #f3f0e8;
  --surface: #fffdf8;
  --ink: #101217;
  --muted: #686b70;
  --line: rgba(16, 18, 23, 0.14);
  --focus: #2563eb;
  --caritana-event-accent: #f04a24;
  --content-width: 1320px;
  --shadow: 0 28px 80px rgba(16, 18, 23, 0.18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; background: var(--background); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--background); }
button, input { font: inherit; }
button, .photo-card, .selfie-file-button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.skip-link { position: fixed; z-index: 100; top: 12px; left: 12px; padding: 10px 14px; color: white; background: var(--ink); border-radius: 6px; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
button:focus-visible, input:focus-visible, .photo-card:focus-visible, .dialog-close:focus-visible, .selfie-file-button:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }

.site-header, footer { width: min(calc(100% - 48px), var(--content-width)); margin-inline: auto; }
main { width: 100%; }
.site-header { position: absolute; z-index: 10; top: 0; left: 0; width: 100%; max-width: none; min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 0; padding: 20px clamp(24px, 6vw, 84px); color: white; background: linear-gradient(180deg, rgba(5,8,12,.68), transparent); }
.brand { min-width: 0; flex: 0 1 auto; display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-weight: 850; letter-spacing: -.035em; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: white; background: rgba(8,12,18,.58); border: 1px solid rgba(255,255,255,.22); border-radius: 8px; font-size: 18px; backdrop-filter: blur(8px); }
.brand-name { font-size: 19px; }
.event-label { min-width: 0; max-width: 55vw; flex: 0 1 auto; overflow: hidden; color: rgba(255,255,255,.9); font-size: 13px; font-weight: 750; text-align: right; text-shadow: 0 1px 12px rgba(0,0,0,.7); text-overflow: ellipsis; white-space: nowrap; }
.caritana-brand-logo { width: auto; max-width: 150px; height: 32px; object-fit: contain; }

.hero { position: relative; isolation: isolate; min-height: max(690px, 100svh); display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, .65fr); align-items: center; gap: clamp(40px, 7vw, 110px); overflow: hidden; padding: clamp(118px, 10vw, 150px) clamp(24px, 6vw, 84px) clamp(56px, 6vw, 88px); color: white; background-image: linear-gradient(90deg, rgba(7,10,14,.9) 0%, rgba(7,10,14,.6) 40%, rgba(7,10,14,.08) 100%), url('/assets/event-hero-multisport-v2.png'); background-position: center; background-size: cover; box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,.35)); pointer-events: none; }
.home-landing .site-header { display: none; }
.home-landing .hero { min-height: 100svh; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: clamp(34px, 6vh, 64px); padding: clamp(44px, 7vh, 84px) clamp(32px, 7vw, 132px); }
.home-landing .hero-copy { position: static; align-self: flex-start; width: min(820px, 62vw); text-align: left; }
.home-landing .hero-copy h1 { max-width: 820px; margin-inline: 0; font-size: clamp(36px, 4.2vw, 68px); line-height: 1.02; }
.home-landing .hero-description:empty { display: none; }
.home-landing .event-finder-panel { position: static; align-self: flex-start; width: min(720px, 86vw); padding: 24px 26px; }
.home-landing .event-finder-panel h2 { margin-bottom: 7px; font-size: clamp(28px, 2.2vw, 38px); }
.home-landing .event-finder-copy { margin-bottom: 18px; }
.home-landing .event-finder-control { grid-template-columns: minmax(0, 1fr) auto; }
.home-landing .event-finder-control button { min-width: 170px; }
.hero-copy { align-self: center; max-width: 760px; }
.eyebrow { margin: 0 0 16px; color: var(--caritana-event-accent); font-size: 11px; font-weight: 900; letter-spacing: .2em; }
.hero .eyebrow { color: white; opacity: .72; }
h1, h2, p { margin-top: 0; }
h1 { max-width: 780px; margin-bottom: 24px; font-size: clamp(58px, 8vw, 112px); line-height: .88; letter-spacing: -.075em; text-wrap: balance; }
.participant-event-name { margin: 0 0 14px; color: white; font-size: clamp(17px, 2vw, 25px); font-weight: 850; letter-spacing: -.02em; }
.participant-event-logo { display: block; width: auto; max-width: min(260px, 70vw); max-height: 125px; margin: 0 0 22px; object-fit: contain; object-position: left center; }
.hero-description { max-width: 660px; margin-bottom: 0; color: rgba(255,255,255,.78); font-size: clamp(17px, 1.7vw, 22px); line-height: 1.55; }

.search-panel { align-self: center; padding: 28px; color: white; background: rgba(8,12,18,.34); border: 1px solid rgba(255,255,255,.22); box-shadow: none; backdrop-filter: blur(8px) saturate(1.05); -webkit-backdrop-filter: blur(8px) saturate(1.05); }
.event-finder-panel { align-self: center; padding: 34px; color: white; background: rgba(8,12,18,.34); border: 1px solid rgba(255,255,255,.22); box-shadow: none; backdrop-filter: blur(8px) saturate(1.05); -webkit-backdrop-filter: blur(8px) saturate(1.05); }
.event-finder-panel .eyebrow { margin-bottom: 12px; color: var(--caritana-event-accent); opacity: 1; }
.event-finder-panel h2 { max-width: 390px; margin-bottom: 12px; font-size: clamp(34px, 3vw, 48px); line-height: .95; letter-spacing: -.055em; }
.event-finder-copy { margin-bottom: 26px; color: rgba(255,255,255,.76); line-height: 1.5; }
.event-finder-form > label { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 800; }
.event-finder-control { display: grid; gap: 10px; }
.event-finder-control input { min-width: 0; min-height: 62px; padding: 0 17px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 0; font-size: 16px; }
.event-finder-control button { min-height: 56px; padding: 0 22px; color: white; background: var(--caritana-event-accent); border: 0; cursor: pointer; font-weight: 820; }
.event-finder-help { margin: 12px 0 0; color: rgba(255,255,255,.7); font-size: 12px; line-height: 1.45; }
.event-finder-error { margin: 13px 0 0; padding: 11px 12px; color: #9f2411; background: #fff0eb; border-left: 3px solid #d9381e; font-size: 13px; font-weight: 750; line-height: 1.45; }
.search-panel-heading { margin-bottom: 24px; }
.search-panel-heading .eyebrow { margin-bottom: 9px; color: var(--caritana-event-accent); opacity: 1; }
.search-panel-heading h2 { margin-bottom: 8px; font-size: clamp(25px, 2.3vw, 34px); line-height: 1; letter-spacing: -.045em; }
.search-panel-heading p { margin: 0; color: rgba(255,255,255,.74); font-size: 14px; }
.search-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 24px; padding: 4px; background: rgba(255,255,255,.12); }
.search-tab { min-height: 44px; padding: 0 14px; color: rgba(255,255,255,.72); background: transparent; border: 0; cursor: pointer; font-weight: 780; transition: color 160ms ease, background 160ms ease; }
.search-tab.is-active { color: var(--ink); background: white; box-shadow: 0 2px 9px rgba(16,18,23,.08); }
.search-tab:disabled { cursor: wait; opacity: .6; }
.search-mode-panel > label { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 800; }
.search-control { display: grid; gap: 10px; }
.search-control input { width: 100%; min-height: 62px; padding: 0 18px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 0; font-size: 22px; font-weight: 750; letter-spacing: .04em; }
.search-control input::placeholder { color: #9da1a8; font-weight: 520; letter-spacing: 0; }
.search-control button, .selfie-search-button, .download-button { min-height: 56px; display: inline-grid; place-items: center; padding: 0 24px; color: white; background: var(--caritana-event-accent); border: 0; border-radius: 0; cursor: pointer; font-weight: 820; transition: filter 160ms ease, transform 160ms ease, opacity 160ms ease; }
.search-control button:hover, .selfie-search-button:hover, .download-button:hover { filter: brightness(.9); transform: translateY(-1px); }
.search-control button:disabled, .selfie-search-button:disabled, .download-button:disabled { cursor: wait; opacity: .62; transform: none; }
.selfie-search-button { width: 100%; margin-top: 12px; }
.search-help { margin: 12px 0 0; color: rgba(255,255,255,.7); font-size: 12px; line-height: 1.5; }
.button-spinner { display: none; width: 19px; height: 19px; border: 2px solid rgba(255,255,255,.35); border-top-color: white; border-radius: 50%; animation: spin 700ms linear infinite; }
.is-loading .button-label { display: none; }
.is-loading .button-spinner { display: block; }

.selfie-picker { display: grid; gap: 12px; }
.selfie-picker > input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.selfie-file-button { min-height: 110px; display: flex; align-items: center; gap: 15px; padding: 18px; background: white; border: 1px dashed rgba(16,18,23,.3); cursor: pointer; transition: border-color 160ms ease, background 160ms ease; }
.selfie-file-button:hover { background: #fafafa; border-color: var(--caritana-event-accent); }
.selfie-file-icon { width: 46px; height: 46px; flex: 0 0 auto; display: grid; place-items: center; color: white; background: var(--ink); font-size: 27px; }
.selfie-file-button strong, .selfie-file-button small { display: block; }
.selfie-file-button strong { margin-bottom: 4px; }
.selfie-file-button small { color: var(--muted); line-height: 1.4; }
.selfie-preview { margin: 0; overflow: hidden; background: #e4e1da; }
.selfie-preview img { width: 100%; max-height: 270px; display: block; object-fit: cover; }
.selfie-preview figcaption { overflow: hidden; padding: 10px 13px; color: var(--muted); background: white; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }

.results-section { width: min(calc(100% - 48px), var(--content-width)); min-height: 420px; margin-inline: auto; padding: clamp(60px, 8vw, 108px) clamp(0px, 2vw, 28px); }
.results-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 34px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.results-heading h2 { margin-bottom: 0; font-size: clamp(36px, 5vw, 70px); line-height: .95; letter-spacing: -.06em; }
.results-count { margin-bottom: 4px; color: var(--muted); font-weight: 750; white-space: nowrap; }
.status-card { min-height: 230px; display: grid; place-items: center; align-content: center; gap: 12px; padding: 30px; color: var(--muted); text-align: center; background: rgba(255,255,255,.38); border: 1px dashed rgba(16,18,23,.22); }
.status-card p { max-width: 520px; margin: 0; line-height: 1.6; }
.status-icon { color: var(--ink); font-size: 38px; }
.photo-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.photo-grid:not([hidden]) { display: grid; }
.photo-card { position: relative; min-width: 0; padding: 0; overflow: hidden; text-align: left; background: #dedbd3; border: 0; border-radius: 0; cursor: pointer; aspect-ratio: 4 / 3; }
.photo-card img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform 300ms ease, filter 300ms ease; }
.photo-card:hover img { transform: scale(1.035); filter: contrast(1.04); }
.photo-card-overlay { position: absolute; inset: auto 0 0; display: flex; align-items: end; justify-content: space-between; gap: 12px; padding: 40px 15px 13px; color: white; background: linear-gradient(transparent, rgba(0,0,0,.8)); }
.photo-card-name { min-width: 0; overflow: hidden; font-size: 13px; font-weight: 780; text-overflow: ellipsis; white-space: nowrap; }
.photo-card-badge { flex: 0 0 auto; padding: 5px 8px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.24); border-radius: 999px; font-size: 10px; font-weight: 850; backdrop-filter: blur(8px); }

footer { padding: 28px 0 44px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
footer p { margin: 0; line-height: 1.65; }
footer a { color: inherit; }

.photo-dialog { width: min(980px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; overflow: hidden; background: white; border: 0; border-radius: 0; box-shadow: 0 30px 100px rgba(16,18,23,.35); }
.photo-dialog::backdrop { background: rgba(8,10,14,.82); backdrop-filter: blur(5px); }
.dialog-shell { position: relative; }
.dialog-close { position: absolute; z-index: 30; top: 12px; right: 12px; width: 42px; height: 42px; display: grid; place-items: center; color: white; background: rgba(16,18,23,.75); border: 0; border-radius: 50%; cursor: pointer; font-size: 27px; line-height: 1; backdrop-filter: blur(8px); }
.dialog-image-shell { position: relative; display: grid; place-items: center; min-height: 280px; max-height: min(68vh, 720px); overflow: hidden; background: #111827; }
.dialog-image-shell img { width: 100%; height: 100%; max-height: min(68vh, 720px); display: block; object-fit: contain; }
.dialog-content { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 20px 22px; }
.dialog-filename { margin-bottom: 5px; font-weight: 800; }
.dialog-meta { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.download-button { flex: 0 0 auto; min-height: 48px; }
.caritana-watermark-layer { position: absolute; inset: 0; z-index: 20; pointer-events: none; user-select: none; background-repeat: repeat; background-position: center; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .hero { min-height: max(690px, calc(100svh - 84px)); grid-template-columns: 1fr; align-items: stretch; gap: 42px; padding: 76px 36px 40px; }
  .hero-copy { padding-top: 60px; }
  .search-panel { max-width: 620px; }
  .home-landing .hero { display: flex; padding: 56px 24px 34px; }
  .home-landing .hero-copy, .home-landing .event-finder-panel { position: static; width: auto; }
  .home-landing .hero-copy { padding-top: 0; }
  .home-landing .event-finder-control { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  footer { width: min(calc(100% - 24px), var(--content-width)); }
  .site-header { right: 0; width: 100%; min-height: 70px; gap: 12px; margin: 0; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left)); }
  .brand { flex-shrink: 1; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-name { font-size: 17px; }
  .caritana-brand-logo { max-width: 120px; height: 28px; }
  .event-label { max-width: none; flex: 1 1 0; font-size: 12px; line-height: 1.25; }
  .hero { min-height: calc(100svh - 70px); padding: 56px 20px 20px; background-position: 62% center; }
  .hero-copy { padding-top: 28px; }
  h1 { margin-bottom: 18px; font-size: clamp(38px, 11.5vw, 52px); line-height: .94; letter-spacing: -.055em; }
  .hero-description { font-size: 16px; }
  .participant-event-logo { max-width: min(190px, 70vw); max-height: 90px; }
  .search-panel { padding: 22px 18px; }
  .search-panel-heading h2 { font-size: 28px; }
  .results-section { width: min(calc(100% - 24px), var(--content-width)); padding-top: 64px; padding-inline: 0; }
  .results-heading { display: block; margin-bottom: 24px; }
  .results-count { margin-top: 9px; }
  .photo-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .photo-card-overlay { display: block; padding: 28px 9px 9px; }
  .photo-card-name { display: block; margin-bottom: 5px; font-size: 10px; }
  .photo-card-badge { display: inline-block; font-size: 8px; }
  .dialog-content { align-items: stretch; flex-direction: column; }
  .download-button { width: 100%; }
}

@media (max-width: 380px) {
  .site-header { gap: 10px; padding-inline: max(12px, env(safe-area-inset-left)); }
  .brand-name { display: none; }
  .event-label { font-size: 11px; }
  h1 { font-size: clamp(36px, 11vw, 44px); }
}

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