/* Cinematic, editorial styling for Who Stood Here. Always dark. */

:root {
    color-scheme: dark; /* always dark, regardless of the device setting */
    --sys-bg: #0c0b0a;
    --card: #171613;
    --fill-2: rgba(244, 241, 234, 0.07);
    --label: #f4f1ea;
    --label-2: rgba(244, 241, 234, 0.56);
    --label-3: rgba(244, 241, 234, 0.3);
    --separator: rgba(244, 241, 234, 0.12);
    --tint: #f4f1ea;
    --green: #9db668;
    --danger: #e5675e;
    --radius-card: 18px;
    --radius-btn: 12px;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
    --serif: "Playfair Display", Georgia, "Times New Roman", serif;
    --mono: "Fragment Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must beat the display rules below. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.4;
    background: var(--sys-bg);
    color: var(--label);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
h1 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }
h2, h3 { letter-spacing: -0.01em; }
a { color: var(--tint); }
button { font-family: inherit; }

/* --- Buttons (iOS filled / pill) ------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 52px;
    padding: 0 1.4rem;
    border: 1px solid var(--separator);
    border-radius: 999px;
    background: transparent;
    color: var(--label);
    font-size: 16px;
    font-weight: 500;
    letter-spacing: .01em;
    text-decoration: none;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: opacity .15s ease, transform .05s ease;
}
.btn-primary { background: #fbf9f4; color: #0c0b0a; border-color: #fbf9f4; font-weight: 600; }
.btn:active { opacity: .6; }
.btn-chip {
    min-height: 40px;
    padding: 0 1rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, .5);
    color: #fff;
    font-size: 15px;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* --- Scan page ------------------------------------------------------ */
.scan-body { background: var(--sys-bg); }
.scan { min-height: 100dvh; }
.stage {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
    gap: 1.5rem;
    text-align: center;
}

/* intro */
.stage-intro { justify-content: center; gap: clamp(2.25rem, 8vh, 4rem); }
.intro-head { padding-top: 0; }
.intro-head .kicker {
    margin: 0 0 .7rem;
    color: var(--label-2);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: .18em;
    text-transform: uppercase;
    font-weight: 400;
}
.intro-head h1 { margin: 0; font-size: 40px; font-weight: 600; line-height: 1.05; }
.intro-head .intro-sub { margin: .7rem auto 0; max-width: 30ch; color: var(--label-2); font-size: 15px; line-height: 1.4; }
.funny { margin-top: .7rem; }
.funny summary { display: inline-block; list-style: none; cursor: pointer; color: var(--label-2); font-size: 15px; line-height: 1.4; text-decoration: underline; text-underline-offset: 2px; -webkit-tap-highlight-color: transparent; }
.funny summary::-webkit-details-marker { display: none; }
.funny p { margin: .55rem auto 0; max-width: 30ch; color: var(--label-2); font-size: 15px; line-height: 1.4; }

.reference-wrap { position: relative; display: inline-flex; max-width: min(90vw, 460px); }
.reference {
    display: block;
    max-width: 100%;
    max-height: 54dvh;
    width: auto;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    object-fit: contain;
}
.reference-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(90vw, 460px);
    height: 42dvh;
    background: var(--card);
    color: var(--label-2);
    border-radius: var(--radius-card);
    border: 1px solid var(--separator);
}

/* Hand-drawn "you?" overlay */
.doodle {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5));
}
.doodle .stroke { stroke-dasharray: 1; stroke-dashoffset: 1; animation: doodle-draw 1.1s ease forwards; }
.doodle .tag {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    font-family: var(--serif);
    font-style: italic;
    font-weight: 500;
    animation: doodle-pop .5s .95s cubic-bezier(.2, 1.5, .4, 1) forwards;
}
@keyframes doodle-draw   { to { stroke-dashoffset: 0; } }
@keyframes doodle-pop    { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }

/* The figures' dance is SVG (SMIL) animation, paused via JS for reduced-motion. */
@media (prefers-reduced-motion: reduce) {
    .doodle .stroke, .doodle .tag {
        animation: none;
        stroke-dashoffset: 0;
        opacity: 1;
    }
}
.intro-cta { width: 100%; max-width: 460px; }
.intro-cta .btn { width: 100%; }
.limit-note { color: var(--label-2); font-size: 15px; line-height: 1.4; margin: 0 auto; max-width: 30ch; }

/* live camera */
.stage-camera { padding: 0; gap: 0; }
.camera-frame { position: fixed; inset: 0; background: #000; }
#viewfinder { width: 100%; height: 100%; object-fit: cover; }
.ghost {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: .35;
    pointer-events: none;
    mix-blend-mode: screen;
}
.ghost.hidden { display: none; }
.camera-controls {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1.5rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, .6));
}
.camera-controls #toggleGhost { justify-self: start; }
.camera-controls #cancel { justify-self: end; }
.shutter {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: #fff;
    border: 4px solid rgba(0, 0, 0, .25);
    box-shadow: 0 0 0 4px #fff inset;
    cursor: pointer;
    justify-self: center;
}
.shutter:active { transform: scale(.92); }

/* fallback */
.stage-fallback p { color: var(--label-2); }
.stage-fallback .btn { width: 100%; max-width: 320px; }

/* thanks */
.checkmark {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    font-size: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pop .5s cubic-bezier(.17, .89, .32, 1.28) both;
}
.stage-thanks h1 { margin: 0; font-size: 32px; font-weight: 600; animation: rise .45s .1s both; }
.stage-thanks p { margin: 0; color: var(--label-2); font-size: 15px; line-height: 1.4; }

/* Optional "tag me" handles on the thanks screen */
.tag-form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: .6rem; margin-top: .25rem; }
.tag-prompt { margin: 0 0 .1rem; color: var(--label-2); font-size: 15px; line-height: 1.4; }
.tag-field { display: flex; flex-direction: column; gap: .3rem; text-align: left; }
.tag-label { font-size: 13px; font-weight: 500; color: var(--label-2); }
.tag-field input {
    min-height: 46px;
    padding: 0 1rem;
    border: 1px solid var(--separator);
    border-radius: var(--radius-btn);
    background: var(--card);
    color: var(--label);
    font-size: 16px;
}
.tag-field input::placeholder { color: var(--label-3); }
.tag-form .btn { margin-top: .3rem; }
.tag-done { margin: .1rem 0 0; color: var(--green); font-size: 15px; text-align: center; }
@keyframes pop  { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* uploading + errors */
.uploading {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-bar {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    margin: 0;
    padding: .9rem 1rem;
    border-radius: var(--radius-btn);
    background: rgba(255, 59, 48, .16);
    color: var(--danger);
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* --- Admin ---------------------------------------------------------- */
.admin-body { background: var(--sys-bg); }
.wrap {
    max-width: 680px;
    margin: 0 auto;
    padding: max(1rem, env(safe-area-inset-top)) 1rem calc(3rem + env(safe-area-inset-bottom));
}

.admin-header { padding: 1rem 0 .5rem; }
.admin-header h1 { margin: 0 0 1.1rem; font-size: 38px; font-weight: 600; }
.new-code { display: flex; gap: .5rem; }
.new-code input {
    flex: 1;
    min-height: 46px;
    padding: 0 1rem;
    border: none;
    border-radius: var(--radius-btn);
    background: var(--card);
    color: var(--label);
    font-size: 17px;
    box-shadow: var(--shadow);
}
.new-code input::placeholder { color: var(--label-3); }

.section-title {
    margin: 1.75rem .5rem .5rem;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--label-2);
}

/* inset grouped list */
.code-list {
    list-style: none;
    margin: .25rem 0 0;
    padding: 0;
    background: var(--card);
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.code-list li + li a { border-top: 0.5px solid var(--separator); }
.code-list a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .85rem 1rem;
    color: var(--label);
    text-decoration: none;
}
.code-list a:active { background: var(--fill-2); }
.code-list .slug { font-family: var(--mono); font-weight: 600; letter-spacing: .03em; }
.code-list .label { flex: 1; color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-counts { display: flex; flex-direction: column; align-items: flex-end; gap: .1rem; font-family: var(--mono); font-size: 12px; color: var(--label-2); white-space: nowrap; }
.code-counts span:last-child { color: var(--label-3); }
.code-list a::after { content: "›"; color: var(--label-3); font-size: 22px; line-height: 1; }

.badge {
    font-size: 12px;
    font-weight: 600;
    padding: .2rem .55rem;
    border-radius: 999px;
    background: var(--fill-2);
    color: var(--label-2);
}

/* detail page */
.back { display: inline-block; margin: .25rem 0 1rem; color: var(--tint); text-decoration: none; }
.back::before { content: "‹ "; }
.code-head { margin: 0 0 1rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem .75rem; }
.code-head h1 { margin: 0; font-size: 32px; font-weight: 600; flex-basis: 100%; }
.scan-url { font-family: var(--mono); font-size: 14px; color: var(--tint); word-break: break-all; }

.code-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.panel {
    background: var(--card);
    border-radius: var(--radius-card);
    padding: 1.25rem;
    margin-top: 1rem;
    box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 1rem; font-size: 17px; font-weight: 600; }
.panel form { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.panel form .btn { flex: 1; }
.panel-actions { display: flex; gap: .5rem; align-items: stretch; margin-top: 1rem; }
.panel-actions > .btn, .panel-actions form { flex: 1; }
.panel-actions form { margin: 0; }
#qr { display: inline-block; background: #fff; padding: 12px; border-radius: 16px; }
/* The QR is generated at high resolution for print; scale the on-screen copy down. */
#qr canvas, #qr img { width: 220px !important; height: 220px !important; display: block; }
.qr-base-field { display: flex; flex-direction: column; gap: .3rem; text-align: left; margin-top: 1rem; }
.qr-base-label { font-size: 13px; font-weight: 500; color: var(--label-2); }
.qr-base-field input { min-height: 44px; padding: 0 .9rem; border: 1px solid var(--separator); border-radius: var(--radius-btn); background: var(--sys-bg); color: var(--label); font-family: var(--mono); font-size: 14px; }
.qr-base-note { margin: .45rem 0 0; font-size: 12px; line-height: 1.45; color: var(--label-3); }
.reference-thumb { max-width: 100%; border-radius: 14px; display: block; }
.muted { color: var(--label-2); }
input[type=file] { font-size: 15px; color: var(--label-2); max-width: 100%; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.shot { position: relative; }
.shot img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; display: block; }
.shot-del { position: absolute; top: 6px; right: 6px; margin: 0; }
.shot-del button {
    width: 28px; height: 28px; padding: 0;
    border: none; border-radius: 50%;
    background: rgba(0, 0, 0, .6); color: #fff;
    font-size: 18px; line-height: 1; cursor: pointer;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.shot-del button:active { background: var(--danger); }
.shot-tags { display: flex; flex-wrap: wrap; gap: .2rem .6rem; margin-top: .35rem; }
.shot-tags a { font-family: var(--mono); font-size: 11px; color: var(--label-2); text-decoration: none; }
.shot-tags a:active { color: var(--label); }

.notice {
    padding: .9rem 1rem;
    border-radius: var(--radius-btn);
    background: rgba(255, 59, 48, .16);
    color: var(--danger);
    font-size: 15px;
    font-weight: 500;
}
.centered { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .5rem; padding: 1.5rem; }

/* "/" landing page */
.landing-body { background: var(--sys-bg); }
.landing { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1rem; padding: 1.5rem; }
.landing .kicker { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--label-2); }
.landing h1 { margin: 0; font-size: 46px; line-height: 1.04; font-weight: 600; }
.landing-sub { margin: .5rem 0 0; color: var(--label-2); font-size: 16px; }
.landing-sub a { color: var(--label); }

/* Landing email capture */
.email-form { display: flex; gap: .5rem; width: 100%; max-width: 360px; margin: .5rem auto 0; }
.email-form input { flex: 1; min-width: 0; min-height: 48px; padding: 0 1rem; border: 1px solid var(--separator); border-radius: var(--radius-btn); background: var(--card); color: var(--label); font-size: 16px; }
.email-form input::placeholder { color: var(--label-3); }
.email-form .btn { white-space: nowrap; }
.email-done { margin: .5rem 0 0; color: var(--label-2); font-size: 16px; }

/* Admin emails */
.admin-titlebar { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.emails-link { font-family: var(--mono); font-size: 13px; color: var(--label-2); text-decoration: none; }
.emails-link:active { color: var(--label); }
.email-list { list-style: none; margin: .25rem 0 0; padding: 0; background: var(--card); border-radius: var(--radius-card); overflow: hidden; box-shadow: var(--shadow); }
.email-list li { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; }
.email-list li + li { border-top: 0.5px solid var(--separator); }
.email-addr { flex: 1; color: var(--label); text-decoration: none; word-break: break-all; }
.email-src { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--label-3); }
.email-date { font-family: var(--mono); font-size: 12px; color: var(--label-3); white-space: nowrap; }

/* Scan hits log */
.hit-log { display: flex; flex-direction: column; }
.hit { padding: .7rem 0; }
.hit + .hit { border-top: 0.5px solid var(--separator); }
.hit-top { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.hit-ip { font-family: var(--mono); font-size: 14px; color: var(--label); }
.hit-date { font-family: var(--mono); font-size: 12px; color: var(--label-3); white-space: nowrap; }
.hit-ua { margin-top: .2rem; font-size: 12px; color: var(--label-2); line-height: 1.35; word-break: break-word; }
.empty { color: var(--label-2); margin-top: 2rem; text-align: center; }
