/* ============================================================
   Halloween-járás – stíluslap (v2)
   Sötét téma, mobilra tervezve. A kontrasztarányok WCAG AA
   szintűek: a régi felületen a #ccc szürke a #333 hátéren
   nem érte el a 4.5:1-et.
   ============================================================ */

:root {
    --bg:            #12100f;
    --surface:       #1e1b19;
    --surface-2:     #2a2523;
    --border:        #3a3331;
    --text:          #f5f0ec;
    --text-dim:      #b9aea8;
    --primary:       #ff6600;
    --primary-dark:  #cc5200;
    --green:         #22c55e;
    --amber:         #f59e0b;
    --blue:          #3b82f6;
    --grey:          #6b7280;
    --red:           #ef4444;
    --radius:        12px;
    --shadow:        0 6px 24px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, .house-card:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.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;
}

/* ---------- Gombok ---------- */
button, .route-btn {
    font: inherit;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 18px;
    cursor: pointer;
    min-height: 44px;              /* érintéshez elég nagy célfelület */
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
button:hover, .route-btn:hover { background: var(--primary-dark); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.secondary { background: var(--surface-2); color: var(--text); }
button.active { background: var(--green); }
.link-btn {
    background: none; color: var(--primary);
    text-decoration: underline; padding: 6px 8px; min-height: 36px;
}

input, select, textarea {
    font: inherit;
    width: 100%;
    padding: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    min-height: 44px;
}
label { display: block; margin: 12px 0 6px; font-weight: 600; }

/* ---------- Belépő oldal ---------- */
.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
.login-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
    max-width: 420px; width: 100%;
    text-align: center;
    box-shadow: var(--shadow);
}
.login-container h1 { color: var(--primary); margin: 8px 0 4px; font-size: 1.6rem; }
.login-container .sub { color: var(--text-dim); margin-top: 0; }
.login-container button { width: 100%; margin-top: 14px; }
.pumpkin { font-size: 3rem; line-height: 1; }
.login-links { margin-top: 20px; font-size: .9rem; color: var(--text-dim); }
.error { color: #ff8f8f; min-height: 1.4em; margin: 12px 0 0; }

@keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}
.shake { animation: shake .4s; }

/* ---------- Betöltés / offline ---------- */
#loading-overlay {
    position: fixed; inset: 0; z-index: 3000;
    background: var(--bg);
    display: grid; place-content: center; justify-items: center; gap: 16px;
}
.spinner {
    width: 44px; height: 44px;
    border: 4px solid var(--surface-2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#offline-bar {
    position: sticky; top: 0; z-index: 900;
    background: var(--amber); color: #1a1a1a;
    text-align: center; padding: 8px 12px; font-weight: 600;
}

/* ---------- Elrendezés ---------- */
.main-container { max-width: 900px; margin: 0 auto; padding: 0 12px 40px; }

.app-header { padding: 16px 4px 8px; }
.app-header h1 { margin: 0 0 12px; font-size: 1.5rem; color: var(--primary); }

#event-progress-container { margin-bottom: 14px; }
#event-timer-text { font-size: .95rem; color: var(--text-dim); margin-bottom: 6px; }
.progress-bar-background {
    background: var(--surface-2); border-radius: 999px; height: 10px; overflow: hidden;
}
#progress-bar-fill {
    height: 100%; width: 0;
    background: var(--primary);
    transition: width 1s linear;
}
#progress-bar-fill.done { background: var(--grey); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters select { width: auto; flex: 1 1 160px; }
.filters button { flex: 0 1 auto; padding: 10px 14px; }

/* ---------- Térkép ---------- */
#map {
    height: 46vh; min-height: 280px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin: 12px 0;
    z-index: 1;
}
.leaflet-container { background: var(--surface); }

/* ---------- Bannerek ---------- */
#trickster-banner, #team-bar, #announcement-banner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px 0;
}
#trickster-banner h2 { margin-top: 0; color: var(--primary); font-size: 1.15rem; }
#team-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#team-label { font-weight: 700; flex: 1 1 auto; }
.small-text { font-size: .85rem; color: var(--text-dim); }
.tiny { font-size: .78rem; color: var(--text-dim); }

#announcement-banner h3 { margin: 0 0 10px; color: var(--amber); }
.announcement {
    border-left: 3px solid var(--amber);
    padding-left: 12px; margin-bottom: 12px;
}
.announcement p { margin: 0; }
.announcement .timestamp { font-size: .8rem; color: var(--text-dim); }

/* ---------- Házlista ---------- */
#house-list-container h2 { font-size: 1.2rem; }
#house-counts { font-size: .75rem; color: var(--text-dim); font-weight: 400; }

#house-list { display: flex; flex-direction: column; gap: 10px; }
.empty-state {
    text-align: center; color: var(--text-dim);
    padding: 32px 16px; background: var(--surface);
    border: 1px dashed var(--border); border-radius: var(--radius);
}

.house-card {
    display: flex; gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s, transform .15s;
}
.house-card:hover { border-color: var(--primary); transform: translateY(-1px); }

.card-thumbnail {
    width: 96px; flex: 0 0 96px;
    background-size: cover; background-position: center;
    background-color: var(--surface-2);
}
.card-thumbnail.placeholder {
    display: grid; place-items: center; font-size: 2rem;
}
.card-content { padding: 12px 12px 12px 0; flex: 1; min-width: 0; }
.card-content .address { margin: 6px 0 2px; font-size: 1.02rem; }
.card-content .details { margin: 0; color: var(--text-dim); font-size: .88rem; }
.card-meta {
    display: flex; flex-wrap: wrap; gap: 10px;
    margin-top: 8px; font-size: .82rem; color: var(--text-dim);
}
.card-distance { color: var(--blue); }

.status-badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .72rem; font-weight: 700; letter-spacing: .03em;
}
.status-badge.open         { background: var(--green); color: #06240f; }
.status-badge.closing-soon { background: var(--amber); color: #2b1a00; }
.status-badge.opening-soon { background: var(--blue);  color: #04162e; }
.status-badge.closed       { background: var(--grey);  color: #0d1116; }

.supply {
    display: inline-block; margin-left: 6px; padding: 3px 8px;
    border-radius: 999px; font-size: .7rem; font-weight: 700;
}
.supply.low { background: #422a06; color: var(--amber); }
.supply.out { background: #3d1414; color: #ff9a9a; }

.route-pick { margin-top: 8px; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.route-pick input { width: auto; min-height: auto; }

#route-hint {
    background: var(--surface-2); border: 1px dashed var(--primary);
    border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.route-actions { display: flex; gap: 8px; margin-top: 10px; }
.route-summary { font-weight: 600; color: var(--primary); }
.route-list { padding-left: 22px; }
.route-list li { margin-bottom: 6px; }

/* ---------- Galéria ---------- */
#trickster-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}
.trickster-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden; cursor: pointer; text-align: center;
}
.trickster-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.trickster-card p { margin: 6px 4px 8px; font-size: .8rem; }

.house-photo-gallery {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px;
}
.house-photo-gallery img {
    width: 100%; aspect-ratio: 1; object-fit: cover;
    border-radius: 8px; cursor: pointer;
}

/* ---------- Modálok ---------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0,0,0,.78);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-overlay[hidden] { display: none; }
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 560px; width: 100%;
    max-height: 88dvh; overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow);
}
.modal-content h2 { margin-top: 0; color: var(--primary); }
.close-btn {
    position: absolute; top: 8px; right: 8px;
    background: none; color: var(--text-dim);
    font-size: 30px; line-height: 1; padding: 6px 12px; min-height: 44px;
}
.close-btn:hover { background: none; color: var(--text); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.modal-actions button, .modal-actions .route-btn { flex: 1 1 auto; }
.organizer-message {
    background: #3a2a06; border-left: 3px solid var(--amber);
    padding: 10px 12px; border-radius: 6px; margin: 12px 0;
}
.supply-banner { padding: 10px 12px; border-radius: 8px; margin: 10px 0; font-weight: 600; }
.supply-banner.low { background: #422a06; color: #ffd28a; }
.supply-banner.out { background: #3d1414; color: #ffb0b0; }

.consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .9rem; }
.consent input { width: auto; min-height: auto; margin-top: 3px; }

#selfie-feedback.ok, #house-photo-feedback.ok, #report-feedback.ok { color: var(--green); }
#selfie-feedback.err, #house-photo-feedback.err, #report-feedback.err { color: #ff8f8f; }

.lightbox { flex-direction: column; }
.lightbox img { max-width: 96vw; max-height: 86dvh; border-radius: 8px; }
.lightbox .close-btn { color: #fff; font-size: 40px; }

hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---------- Lábléc ---------- */
.app-footer {
    margin-top: 32px; padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center; color: var(--text-dim); font-size: .88rem;
}

/* ---------- Űrlapok ---------- */
.form-page { max-width: 720px; margin: 0 auto; padding: 20px 16px 60px; }
.form-page h1 { color: var(--primary); text-align: center; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px;
}
.form-group { margin-bottom: 18px; }
.checkbox-group, .radio-group {
    display: flex; flex-direction: column; gap: 10px;
    background: var(--surface-2); padding: 14px; border-radius: 8px;
}
.checkbox-group label, .radio-group label {
    display: flex; align-items: center; gap: 10px;
    margin: 0; font-weight: 400;
}
.checkbox-group input, .radio-group input { width: auto; min-height: auto; }
.message { background: #10391f; border: 1px solid var(--green); color: #b7f0cd;
           padding: 14px; border-radius: 8px; margin-bottom: 18px; }
.alert-error { background: #3d1414; border: 1px solid var(--red); color: #ffc0c0;
               padding: 14px; border-radius: 8px; margin-bottom: 18px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Mozgáscsökkentés ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

@media (max-width: 480px) {
    .card-thumbnail { width: 78px; flex-basis: 78px; }
    .app-header h1 { font-size: 1.3rem; }
    .modal-content { padding: 20px 16px; }
}

/* A [hidden] attributum mindig rejtsen. Enelkul az olyan elemek, amiknek
   sajat display-szabalya van (pl. #team-bar { display:flex }), "hidden"
   mellett is lathatok maradtak: a csapat nelkuli latogato egy ures
   savot latott "Csapatkep cseréje / Mentés másik eszközre" gombokkal. */
[hidden] { display: none !important; }

/* Útvonal megnyitása külső térképen */
.route-open-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.route-open-actions .route-btn { text-align: center; }
.apple-maps-help { margin-top: 12px; }
.apple-maps-help summary { cursor: pointer; color: var(--primary); }
.apple-stop-link { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }

/* Modal-urlapok: egyenletes kozok (a "Problemat jeleznek" ujrarajzolt
   valasztomezoje es a kuldes gomb korabban egymasra csuszott). */
.modal-content form { display: grid; gap: 14px; }
.modal-content form label { margin: 0 0 -6px; }
.modal-content form label.consent { margin: 0; }
.modal-content form button[type="submit"] { justify-self: start; }
.modal-content form .small-text { margin: -8px 0 0; }
.modal-content textarea { resize: vertical; min-height: 88px; }

.team-help { margin-top: 12px; }
.team-help summary { cursor: pointer; color: var(--primary); font-size: .9rem; }
.team-help p { margin: 8px 0 0; }

/* ---------- Üzenőfal (chat.js) – mobil először ---------- */
.chat-btn {
    position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 1500; min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px;
    background: var(--primary); color: #1a0e05; font: inherit; font-weight: 700;
    box-shadow: var(--shadow); cursor: pointer;
}
.chat-btn[hidden], .chat-panel[hidden] { display: none !important; }
.chat-badge {
    display: inline-block; margin-left: 8px; min-width: 22px; padding: 0 6px; border-radius: 999px;
    background: #12100f; color: #fff; font-size: .8rem; line-height: 22px; text-align: center;
}
.chat-panel {
    position: fixed; z-index: 3500; left: 0; right: 0; bottom: 0; height: min(80vh, 640px);
    display: flex; flex-direction: column; background: var(--surface);
    border: 1px solid var(--border); border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 640px) {
    .chat-panel { left: auto; right: 16px; bottom: 16px; width: 380px; border-radius: 16px; }
}
.chat-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 0; }
.chat-top h2 { margin: 0; font-size: 1.1rem; }
.chat-close { min-width: 44px; min-height: 44px; border: 0; background: none; color: var(--text); font-size: 1.2rem; cursor: pointer; }
.chat-rules { margin: 0; padding: 4px 14px 8px; font-size: .8rem; color: var(--text-dim); }
.chat-list { flex: 1; overflow-y: auto; padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.chat-empty { color: var(--text-dim); text-align: center; margin: 24px 0; }
.chat-msg { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; max-width: 92%; align-self: flex-start; overflow-wrap: anywhere; }
.chat-msg.chat-own { align-self: flex-end; background: #3b2412; }
.chat-msg.chat-admin { background: #3a1b52; border: 1px solid #7c3aed; }
.chat-msg.chat-house { border-left: 3px solid var(--amber); }
.chat-head { display: flex; gap: 10px; justify-content: space-between; font-size: .8rem; color: var(--text-dim); }
.chat-head strong { color: var(--text); }
.chat-body { font-size: .95rem; white-space: pre-wrap; }
.chat-flag { margin-top: 2px; padding: 4px 0; min-height: 28px; border: 0; background: none; color: var(--text-dim); font-size: .75rem; text-decoration: underline; cursor: pointer; }
.chat-flag:disabled { text-decoration: none; }
.chat-closed { margin: 0; padding: 10px 14px; background: var(--surface-2); color: var(--amber); font-size: .9rem; }
.chat-form { padding: 8px 12px 12px; display: grid; gap: 6px; }
.chat-who { margin: 0; font-size: .8rem; color: var(--text-dim); }
.chat-namewrap { display: grid; gap: 4px; font-size: .85rem; }
.chat-form input { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
.chat-row { display: flex; gap: 8px; }
.chat-row input { flex: 1; min-width: 0; }
.chat-row button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--primary); color: #1a0e05; font: inherit; font-weight: 700; cursor: pointer; }
.chat-row button:disabled { opacity: .6; }
.chat-meta { margin: 0; text-align: right; font-size: .75rem; color: var(--text-dim); }
.chat-note { margin: 0; min-height: 1.2em; font-size: .85rem; color: var(--green); }
.chat-note.chat-err { color: #ff8f8f; }

/* Nagyobb, ujjal jobban eltalálható jelölőnégyzetek és rádiógombok */
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--primary); flex-shrink: 0; }
