/* ============================================================
   Daan's Bruiloft Gallery — mobile-first styling
   ============================================================ */

:root {
    --bg: #faf6f1;
    --surface: #ffffff;
    --primary: #8c2f39;
    --primary-dark: #6f242c;
    --accent: #c8a24a;
    --text: #3a2f2c;
    --muted: #8a7f78;
    --border: #ece4db;
    --danger: #b23b3b;
    --shadow: 0 6px 20px rgba(90, 54, 40, 0.10);
    --radius: 16px;
    --radius-sm: 10px;
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* Ensure the [hidden] attribute always wins, even over components that set
   their own display (e.g. .modal / .lightbox use display:flex). Without this,
   the share modal and lightbox would show on page load. */
[hidden] { display: none !important; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

a { color: var(--primary); text-decoration: none; }

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

/* ---------- Header ---------- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
    padding-left: var(--safe-l); padding-right: var(--safe-r);
}
.header-inner {
    max-width: 1100px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 10px 16px;
}
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-mark { font-size: 1.3rem; }
.brand-text {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 1.5rem; font-weight: 600; color: var(--primary); letter-spacing: .3px;
}
.site-nav { display: flex; gap: 4px; }
.site-nav a {
    color: var(--text); font-weight: 600; font-size: .9rem;
    padding: 8px 10px; border-radius: 999px; min-height: 40px;
    display: inline-flex; align-items: center;
}
.site-nav a:hover { background: var(--bg); color: var(--primary); }

/* ---------- Layout ---------- */
.site-main {
    flex: 1;
    width: 100%; max-width: 1100px; margin: 0 auto;
    padding: 20px 16px calc(40px + var(--safe-b));
    padding-left: calc(16px + var(--safe-l));
    padding-right: calc(16px + var(--safe-r));
}
.site-footer {
    text-align: center; color: var(--muted); font-size: .8rem;
    padding: 20px 16px calc(20px + var(--safe-b));
    border-top: 1px solid var(--border);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 12px 20px;
    border-radius: 999px; border: 1px solid transparent;
    font: inherit; font-weight: 700; font-size: 1rem;
    cursor: pointer; text-align: center; line-height: 1;
    transition: transform .06s ease, background .15s ease, box-shadow .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn-ico { font-size: 1.1em; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-secondary:hover { background: #fff3f2; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-block { width: 100%; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 12px 0 20px; }
.hero-kicker {
    text-transform: uppercase; letter-spacing: 3px; font-size: .72rem;
    color: var(--accent); font-weight: 700; margin: 0 0 4px;
}
.hero-title {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: clamp(2.6rem, 12vw, 4.5rem); font-weight: 600;
    color: var(--primary); margin: 0; line-height: 1;
}
.hero-sub { color: var(--muted); margin: 10px auto 0; max-width: 30ch; }

/* ---------- Uploader ---------- */
.uploader {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px; margin: 8px 0 28px; text-align: center;
}
.upload-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; width: 100%; min-height: 170px; padding: 28px 16px;
    border: 2px dashed var(--primary); border-radius: var(--radius);
    background: #fff6f5; color: var(--primary); cursor: pointer;
    transition: background .15s ease, transform .06s ease;
    -webkit-tap-highlight-color: transparent;
}
.upload-drop:hover { background: #ffeeec; }
.upload-drop:active { transform: scale(.99); }
.upload-plus { font-size: 3.4rem; line-height: 1; font-weight: 300; }
.upload-text { font-size: 1.15rem; font-weight: 700; }
.upload-secondary { margin-top: 14px; }
.upload-status {
    margin-top: 12px; font-size: .9rem; font-weight: 600;
    padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg);
}
.upload-status.error { color: var(--danger); }
.upload-status.busy { color: var(--primary); }
.upload-status.done { color: #2e7d4f; }

/* ---------- Grid ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 10px; } }
@media (min-width: 820px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 12px; } }
@media (min-width: 1040px) { .grid { grid-template-columns: repeat(5, 1fr); } }

.tile {
    padding: 0; border: none; background: var(--border);
    border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
    aspect-ratio: 1 / 1; position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: transform .12s ease, box-shadow .12s ease;
}
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile:hover { box-shadow: var(--shadow); }
.tile:active { transform: scale(.98); }

/* ---------- Empty state ---------- */
.empty-state {
    text-align: center; color: var(--muted);
    padding: 48px 16px; background: var(--surface);
    border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-emoji { font-size: 2.5rem; display: block; margin-bottom: 8px; }

/* ---------- Lightbox ---------- */
.lightbox {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(20, 12, 10, .94);
    display: flex; align-items: center; justify-content: center;
    padding: calc(16px + var(--safe-b)) 12px;
    touch-action: none;
}
.lightbox-img {
    max-width: 100%; max-height: 100%;
    object-fit: contain; border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.lightbox-close, .lightbox-nav {
    position: absolute; background: rgba(255,255,255,.14); color: #fff;
    border: none; cursor: pointer; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.lightbox-close {
    top: calc(12px + env(safe-area-inset-top, 0px)); right: 14px;
    width: 48px; height: 48px; font-size: 1.8rem; line-height: 1;
}
.lightbox-nav { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; font-size: 2rem; }
.lightbox-nav.prev { left: 8px; }
.lightbox-nav.next { right: 8px; }
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,.28); }
@media (min-width: 700px) {
    .lightbox-nav.prev { left: 20px; }
    .lightbox-nav.next { right: 20px; }
}

/* ---------- Modal (share) ---------- */
.modal {
    position: fixed; inset: 0; z-index: 60;
    background: rgba(20, 12, 10, .55);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
    background: var(--surface); border-radius: var(--radius);
    padding: 26px 22px; max-width: 360px; width: 100%;
    text-align: center; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-close {
    position: absolute; top: 10px; right: 12px;
    width: 40px; height: 40px; border: none; background: transparent;
    font-size: 1.6rem; color: var(--muted); cursor: pointer; border-radius: 999px;
}
.modal-close:hover { background: var(--bg); }
.modal-title { font-family: "Cormorant Garamond", serif; color: var(--primary); margin: 0 0 6px; font-size: 1.7rem; }
.modal-sub { color: var(--muted); font-size: .9rem; margin: 0 0 16px; }
.qr-holder {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px; margin: 0 auto 16px; width: fit-content;
}
.qr-holder img { width: 220px; height: 220px; }

/* ---------- Share page ---------- */
.share-page { text-align: center; max-width: 460px; margin: 0 auto; }
.share-title { font-family: "Cormorant Garamond", serif; color: var(--primary); font-size: 2.4rem; margin: 8px 0 4px; }
.share-sub { color: var(--muted); margin: 0 auto 22px; max-width: 34ch; }
.qr-card {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px; width: fit-content; margin: 0 auto 22px;
}
.qr-large { width: min(78vw, 320px); height: min(78vw, 320px); }
.share-link { display: flex; gap: 8px; }
.share-link input {
    flex: 1; min-width: 0; padding: 12px 14px; font: inherit;
    border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--text);
}
.copy-feedback { color: #2e7d4f; font-weight: 700; font-size: .9rem; height: 1.2em; margin: 8px 0 0; }
.share-print-hint { color: var(--muted); font-size: .85rem; margin-top: 24px; }

/* ---------- Auth ---------- */
.auth-page { display: flex; justify-content: center; padding: 24px 0; }
.auth-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 28px 24px; width: 100%; max-width: 380px;
}
.auth-title { font-family: "Cormorant Garamond", serif; color: var(--primary); margin: 0 0 4px; font-size: 2rem; }
.auth-sub { color: var(--muted); margin: 0 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-weight: 700; font-size: .9rem; }
.field-input {
    padding: 14px; font: inherit; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: #fff; color: var(--text); width: 100%;
}
.field-input:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.auth-form .btn { margin-top: 12px; }
.form-error { color: var(--danger); font-weight: 600; font-size: .9rem; }
.form-error ul { margin: 0; padding-left: 18px; }
.form-error:empty { display: none; }

/* ---------- Admin ---------- */
.admin-bar {
    display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
}
.admin-bar-info { display: flex; align-items: baseline; gap: 12px; }
.admin-title { font-family: "Cormorant Garamond", serif; color: var(--primary); margin: 0; font-size: 2rem; }
.admin-count { color: var(--muted); font-weight: 600; }
.admin-bar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form { margin: 0; }
.admin-hint { color: var(--muted); font-size: .88rem; margin: 6px 0 4px; }
.reorder-status { color: var(--primary); font-weight: 700; font-size: .85rem; margin: 4px 0; }

.admin-grid { margin-top: 12px; }
.admin-tile {
    position: relative; margin: 0; background: var(--border);
    border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 1 / 1;
}
.admin-tile img { width: 100%; height: 100%; object-fit: cover; }
.admin-tile.sortable-ghost { opacity: .35; }
.admin-tile.sortable-chosen { box-shadow: 0 0 0 3px var(--accent); }
.drag-handle {
    position: absolute; top: 6px; left: 6px; z-index: 2;
    background: rgba(0,0,0,.45); color: #fff; border-radius: 8px;
    padding: 4px 8px; font-size: .8rem; cursor: grab; letter-spacing: -2px;
    touch-action: none;
}
.tile-delete {
    position: absolute; top: 6px; right: 6px; z-index: 2;
    width: 36px; height: 36px; border-radius: 999px; border: none;
    background: rgba(178, 59, 59, .9); color: #fff; font-size: 1.3rem; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.tile-delete:hover { background: var(--danger); }

/* ---------- Print (share page) ---------- */
@media print {
    .site-header, .site-footer, .share-link, .share-print-hint, #copy-url { display: none !important; }
    body { background: #fff; }
}
