/* ============================================
   Histinguish — Stylesheet
   Design-Tokens aus Figma extrahiert.
   Typografie via ui-rounded (= SF Pro Rounded auf iOS).
   ============================================ */

:root {
    /* Background tones (smoky warm brown) */
    --bg-base:        #1f1812;
    --bg-base-2:      #2a2018;
    --bg-card:        #3d2f24;
    --bg-card-light:  #5a4435;
    --bg-tabbar:      rgba(240, 235, 230, 0.78);

    /* Accents */
    --orange:         #f5a623;
    --orange-light:   #ffc87a;
    --orange-pale:    #ffe4ba;

    /* Text */
    --text:           #ffffff;
    --text-on-light:  #1a1410;
    --text-muted:     rgba(255, 255, 255, 0.45);

    /* Standard radii & spacing */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 28px;
    --radius-pill: 9999px;

    --space-1: 0.5rem;
    --space-2: 1rem;
    --space-3: 1.5rem;
    --space-4: 2rem;
    --space-6: 3rem;

    /* Safe-area for notch / home-indicator */
    --safe-top:    env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);

    /* Typography */
    --font-display: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN",
                    "Quicksand", "Comfortaa", system-ui, sans-serif;
    --font-body:    -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
                    "Helvetica Neue", Arial, sans-serif;
}

/* --------- Reset --------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
    user-select: none;
}
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: transparent; }
a { color: inherit; text-decoration: none; }

/* --------- Background atmosphere --------- */
body::before {
    content: "";
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse 90% 60% at 50% 110%, rgba(120, 75, 40, 0.55), transparent 70%),
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(60, 40, 30, 0.6), transparent 70%),
        var(--bg-base);
    z-index: -2;
    pointer-events: none;
}
body::after {
    content: "";
    position: fixed; inset: 0;
    background-image: var(--bg-image, none);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.85;
    z-index: -1;
    pointer-events: none;
    mix-blend-mode: screen;
}

/* --------- Shell layout --------- */
.shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
    padding-top: calc(var(--safe-top));
    padding-bottom: calc(var(--safe-bottom) + 96px); /* room for tab bar */
    position: relative;
}

/* --------- Header logo --------- */
.brand {
    text-align: center;
    padding: var(--space-3) var(--space-3) var(--space-2);
}
.brand__logo {
    display: inline-block;
    width: min(78%, 320px);
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}

/* --------- Tab bar --------- */
.tabbar {
    position: fixed;
    bottom: calc(var(--safe-bottom) + 12px);
    left: 50%;
    transform: translateX(-50%);
    width: min(calc(100% - 24px), 460px);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
}
.tabbar__pill {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    background: var(--bg-tabbar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-pill);
    padding: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.tabbar__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 4px;
    color: #1a1410;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-pill);
    transition: background 0.15s;
    text-decoration: none;
}
.tabbar__item svg { width: 22px; height: 22px; }
.tabbar__item--active {
    color: var(--orange);
    background: rgba(245, 166, 35, 0.12);
}
.tabbar__item--active svg { color: var(--orange); }
.tabbar__profile {
    flex: 0 0 auto;
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--bg-tabbar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    color: #1a1410;
    text-decoration: none;
}
.tabbar__profile--active { color: var(--orange); }
.tabbar__profile svg { width: 24px; height: 24px; }

/* ============================================
   Page: Simulation menu (index.html)
   ============================================ */
.menu-content {
    flex: 1;
    padding: var(--space-3) var(--space-3);
    display: flex;
    flex-direction: column;
}
.menu-title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    margin: var(--space-3) 0 var(--space-3);
    text-align: center;
}
.scenarios {
    background: rgba(40, 30, 22, 0.85);
    border-radius: var(--radius-md);
    padding: var(--space-2);
    list-style: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.scenario {
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 14px 16px;
    font-size: 1.4rem;
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--text);
    background: transparent;
    border-radius: var(--radius-sm);
}
.scenario__icon { font-size: 1.6rem; line-height: 1; }
.scenario--locked { color: var(--text-muted); }
.scenario:active { background: rgba(255, 255, 255, 0.06); }

.btn-instructions {
    margin: var(--space-3) auto 0;
    width: 100%;
    max-width: 360px;
    background: var(--orange);
    color: var(--text-on-light);
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    padding: 14px 24px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-shadow: 0 6px 16px rgba(245, 166, 35, 0.35);
}
.btn-instructions__icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--orange-pale);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}
.btn-instructions:active { transform: scale(0.98); }

/* ============================================
   Page: AR Scenario (Küchenbrand)
   ============================================ */
.ar-stage {
    flex: 1;
    position: relative;
    overflow: hidden;
    margin: var(--space-2) 0 0;
}
.ar-stage__img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
/* Invisible tap targets over the baked-in extinguisher labels.
   Positions are percentages of the cropped 880x1380 image. */
.hotspot {
    position: absolute;
    background: transparent;
    border: 0;
    cursor: pointer;
    border-radius: var(--radius-md);
}
.hotspot--schaum {
    /* Schaumlöscher label + extinguisher area */
    top: 22%; left: 25%;
    width: 50%; height: 38%;
}
.hotspot--hydrat {
    /* Hydratlöscher label + extinguisher area */
    top: 38%; left: 50%;
    width: 50%; height: 38%;
}
.hotspot:focus-visible {
    outline: 3px solid var(--orange);
    outline-offset: 2px;
}

/* ============================================
   Page: Geschichte
   ============================================ */
.history-content {
    flex: 1;
    padding: 0 var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.history-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-3);
}
.history-card h2 {
    font-family: var(--font-display);
    font-size: 1.9rem;
    font-weight: 600;
    margin-bottom: var(--space-2);
    line-height: 1.1;
}
.history-card p { font-size: 1rem; line-height: 1.45; }

.history-cta {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}
.history-cta em { font-style: normal; color: var(--orange); }

.artifact {
    text-align: center;
    padding-bottom: var(--space-3);
}
.artifact model-viewer {
    width: 100%;
    height: 320px;
    background: transparent;
    --poster-color: transparent;
}
.artifact h3 {
    margin-top: var(--space-2);
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 500;
}
.artifact h3 span { display: block; opacity: 0.7; font-size: 0.95rem; }

.artifact-ar-button {
    background: var(--orange);
    color: var(--text-on-light);
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(245, 166, 35, 0.35);
    position: absolute;
    bottom: 12px;
    right: 12px;
}

/* ============================================
   Page: Rangliste
   ============================================ */
.leaderboard {
    flex: 1;
    padding: 0 var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.podium {
    background: linear-gradient(180deg, #f5a623 0%, #e69612 100%);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    color: var(--text-on-light);
    position: relative;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.podium__title {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 600;
    margin-bottom: var(--space-3);
}
.podium__medal {
    position: absolute;
    top: 14px; left: 14px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--orange-pale);
    display: flex; align-items: center; justify-content: center;
}
.podium__bars {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: end;
    gap: 8px;
    height: 220px;
}
.podium__bar {
    background: linear-gradient(180deg, #fff 0%, #fce8b8 100%);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: 14px 8px 12px;
    text-align: center;
    color: var(--text-on-light);
    position: relative;
    font-family: var(--font-display);
    font-weight: 500;
}
.podium__bar--1 { height: 100%; }
.podium__bar--2 { height: 75%; }
.podium__bar--3 { height: 60%; }
.podium__avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: #d8e1ec;
    margin: -32px auto 6px;
    border: 3px solid #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
}
.podium__rank {
    position: absolute;
    bottom: 8px; left: 50%; transform: translateX(-50%);
    font-size: 0.95rem; font-weight: 600;
    color: #000;
}
.podium__name { font-size: 1.05rem; font-weight: 600; }
.podium__score { font-size: 0.95rem; opacity: 0.85; }

.rank-row {
    background: #fff;
    color: var(--text-on-light);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 32px 56px 1fr auto;
    align-items: center;
    gap: 12px;
    font-family: var(--font-display);
}
.rank-row--self {
    background: var(--orange);
    position: relative;
    margin-top: 22px;
}
.rank-row--self::before {
    content: "Dein Score";
    position: absolute;
    top: -18px; left: 0; right: 0; margin: 0 auto;
    width: fit-content;
    background: #fff;
    color: var(--text-on-light);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 16px;
    border-radius: var(--radius-pill) var(--radius-pill) 0 0;
}
.rank-row__num { font-weight: 600; font-size: 1rem; opacity: 0.8; }
.rank-row__avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: #d8e1ec;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.rank-row__name { font-weight: 600; font-size: 1.05rem; }
.rank-row__score { font-size: 1rem; }

.leaderboard__list {
    background: rgba(40, 30, 22, 0.7);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-2) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: var(--space-2);
}

/* ============================================
   Page: Profil
   ============================================ */
.settings-content {
    flex: 1;
    padding: 0 var(--space-3);
}
.settings-title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 600;
    margin-bottom: var(--space-3);
}
.settings-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    align-items: center;
    margin-bottom: var(--space-2);
    gap: var(--space-2);
}
.settings-row label {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 500;
}
.settings-input,
.settings-select {
    width: 100%;
    background: #fff;
    color: var(--text-on-light);
    border-radius: var(--radius-pill);
    padding: 12px 18px;
    font: inherit;
    font-size: 1.05rem;
    border: 3px solid var(--bg-card-light);
}
.settings-select {
    /* Use native iOS picker chrome */
    appearance: auto;
    -webkit-appearance: menulist-button;
}

/* ============================================
   Dialogs (use native <dialog>)
   ============================================ */
dialog {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--text-on-light);
    max-width: 100%;
    max-height: 100%;
}
dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
}

/* Bottom-sheet dialog (Anleitung, Auswertung) */
.sheet {
    position: fixed;
    inset: auto 0 0 0;
    background: #fff;
    color: var(--text-on-light);
    border-radius: 28px 28px 0 0;
    padding: 28px 24px calc(var(--safe-bottom) + 24px);
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
    animation: sheet-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 92vh;
    overflow-y: auto;
}
@keyframes sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.sheet__head {
    display: flex; align-items: center; justify-content: center;
    margin-bottom: var(--space-3);
    position: relative;
}
.sheet__close {
    position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    color: var(--text-on-light);
}
.sheet__title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
}
.sheet__body {
    font-size: 1.1rem;
    line-height: 1.45;
}
.sheet__body strong { font-weight: 700; }

/* Result sheet (Auswertung) */
.result-sheet { padding-top: 22px; }
.result-sheet__title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.05;
    margin-bottom: 4px;
}
.result-sheet__sub {
    color: rgba(0, 0, 0, 0.5);
    font-size: 1rem;
    margin-bottom: var(--space-2);
}
.result-sheet__points {
    display: inline-block;
    background: var(--bg-card);
    color: #fff;
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-weight: 500;
    margin-bottom: var(--space-3);
}
.result-sheet h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.5rem;
    margin: var(--space-3) 0 var(--space-1);
}
.result-sheet p {
    font-size: 1rem;
    line-height: 1.45;
    margin-bottom: var(--space-2);
}
.used-extinguisher {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: var(--space-2);
    align-items: start;
    margin-top: var(--space-2);
}
.used-extinguisher model-viewer {
    width: 110px;
    height: 220px;
    background: transparent;
}
.used-extinguisher__caption {
    text-align: center;
    margin-top: var(--space-1);
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 500;
}
.result-sheet__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: var(--space-3);
}
.btn-pill {
    border-radius: var(--radius-pill);
    padding: 14px 16px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.1;
    text-align: center;
    text-decoration: none;
}
.btn-pill--primary { background: var(--orange); color: var(--text-on-light); }
.btn-pill--secondary { background: rgba(0, 0, 0, 0.05); color: var(--text-on-light); }
.btn-pill svg { width: 20px; height: 20px; flex: 0 0 auto; }

/* =============== Utility =============== */
.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0);
}
