/* ==========================================================================
   Dahin design system + app shell (Phase 3A)

   Single authored stylesheet for the Dahin frontend. Tokens are ported from
   the MA-Thesis prototype (app/css/styles.css) and reduced to the shell,
   onboarding and legal surfaces; the event, calendar and map views extend
   this file. Fonts are self-hosted Archivo / Archivo Black (see fonts.css).
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */

:root {
    /* Palette - opaque base colors only */
    --papier: #eeede9;
    --tinte: #111;
    --schwarz: #000;
    --orange: #d0411f;
    --orange-dunkel: #a8341a;
    --hell: #f5f5f5;
    --grau-dunkel: #403f3f;
    --grau: #666;
    --nachtschwarz: #1c1c1c;

    /* RGB triples for transparencies */
    --rgb-schwarz: 0 0 0;
    --rgb-hell: 245 245 245;
    --rgb-orange: 208 65 31;

    /* Opacity scale - only these eight steps */
    --o1: 12%;
    --o2: 20%;
    --o3: 30%;
    --o4: 45%;
    --o5: 55%;
    --o6: 70%;
    --o7: 80%;
    --o8: 90%;

    /* Geometry */
    --radius: 4px;
    --border-width: 2px;
    --line: 1px solid rgb(var(--rgb-schwarz) / var(--o2));
    --app-max: 480px;
    --frame-gap: 24px;
    --topbar-pad: 20px;
    --tabbar-height: 96px;

    /* Type */
    --font-body: "Archivo", -apple-system, blinkmacsystemfont, "Segoe UI", roboto, sans-serif;
    --font-display: "Archivo Black", "Archivo", -apple-system, blinkmacsystemfont, "Segoe UI", sans-serif;
}

/* --------------------------------------------------------------------------
   Reset / base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--orange);
    color: var(--tinte);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    text-size-adjust: 100%;
}

h1,
h2,
h3,
p,
ul,
ol,
figure {
    margin: 0;
}

ul,
ol {
    padding: 0;
    list-style: none;
}

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

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 3px solid var(--tinte);
    outline-offset: 2px;
}

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

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 200;
    padding: 10px 16px;
    background: var(--tinte);
    color: var(--papier);
    border-radius: var(--radius);
    transform: translateY(-160%);
    transition: transform 140ms ease;
}

.skip-link:focus {
    transform: none;
}

/* --------------------------------------------------------------------------
   Shell: phone-first app frame
   -------------------------------------------------------------------------- */

.shell {
    position: relative;
    display: grid;
    grid-template:
        "header" auto
        "main" minmax(0, 1fr)
        "tabbar" auto
        / minmax(0, 1fr);
    width: 100%;
    max-width: var(--app-max);
    height: 100vh;
    height: 100dvh;
    margin-inline: auto;
    overflow: hidden;
    background: var(--papier);
}

/* Header ------------------------------------------------------------------ */

.topbar {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px var(--topbar-pad);
    padding-top: calc(12px + env(safe-area-inset-top));
    background: var(--orange);
}

.topbar__brand-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    border-radius: var(--radius);
}

.topbar__brand {
    width: auto;
    height: 26px;
    filter: brightness(0);
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.topbar__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
}

.topbar__action img {
    width: 22px;
    height: 22px;
    filter: brightness(0);
}

.topbar__action:hover {
    background: rgb(var(--rgb-schwarz) / var(--o1));
}

/* Side navigation (desktop only) ------------------------------------------ */

.sidenav {
    display: none;
}

/* Main content ------------------------------------------------------------ */

.main {
    grid-area: main;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--papier);
}

.content {
    width: 100%;
    max-width: 760px;
    margin-inline: auto;
    padding: 28px var(--topbar-pad) 40px;
}

/* Context column (three-column desktop only) ------------------------------ */

.aside {
    display: none;
}

/* Bottom tab bar ---------------------------------------------------------- */

.tabbar {
    grid-area: tabbar;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 44px;
    padding: 14px 8px calc(30px + env(safe-area-inset-bottom));
    background: var(--orange);
}

.tabbar__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
    padding: 4px;
    border-radius: var(--radius);
    opacity: 0.85;
    transition: transform 120ms ease, opacity 120ms ease;
}

.tabbar__btn img {
    width: 40px;
    height: 40px;
    filter: brightness(0);
}

/* The house icon ships as a light silhouette with knocked-out detail. */
.tabbar__btn--home img {
    filter: none;
}

.tabbar__btn.is-active {
    opacity: 1;
    box-shadow: inset 0 -3px 0 var(--schwarz);
}

.tabbar__btn:active {
    transform: scale(0.92);
}

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

.eyebrow {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgb(var(--rgb-schwarz) / var(--o6));
}

.display {
    font-family: var(--font-display);
    font-size: clamp(2rem, 10vw, 2.625rem);
    font-weight: 400;
    line-height: 0.92;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    color: var(--orange);
    overflow-wrap: break-word;
}

.display + .lead {
    margin-top: 16px;
}

.lead {
    max-width: 60ch;
    font-size: 1.0625rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--tinte);
}

.section-title {
    margin-top: 36px;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    color: var(--tinte);
}

.muted {
    color: rgb(var(--rgb-schwarz) / var(--o6));
}

/* --------------------------------------------------------------------------
   Buttons and links
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 48px;
    padding: 12px 22px;
    border: var(--border-width) solid var(--tinte);
    border-radius: var(--radius);
    background: var(--tinte);
    color: var(--papier);
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

.btn:hover {
    background: var(--orange-dunkel);
    border-color: var(--orange-dunkel);
    color: var(--papier);
}

.btn:active {
    transform: scale(0.98);
}

.btn--ghost {
    background: transparent;
    color: var(--tinte);
}

.btn--ghost:hover {
    background: var(--tinte);
    color: var(--papier);
}

.link {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
}

.link:hover {
    color: var(--orange-dunkel);
}

/* --------------------------------------------------------------------------
   Cards, stamps, texture
   -------------------------------------------------------------------------- */

.card {
    padding: 20px;
    background: var(--hell);
    border: var(--line);
    border-radius: var(--radius);
}

.stamp {
    display: inline-block;
    padding: 3px 9px;
    border: var(--border-width) solid currentcolor;
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transform: rotate(-1.5deg);
}

.halftone {
    background-image: radial-gradient(circle, rgb(var(--rgb-schwarz) / var(--o2)) 1px, transparent 1px);
    background-size: 6px 6px;
}

.paper-grain {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background-image: url("/static/dahin/splash-bg.jpg");
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    mix-blend-mode: multiply;
    opacity: 0.5;
}

/* --------------------------------------------------------------------------
   Splash
   -------------------------------------------------------------------------- */

.page--splash .topbar,
.page--splash .sidenav,
.page--splash .aside,
.page--splash .tabbar {
    display: none;
}

.page--splash .shell {
    max-width: var(--app-max);
    grid-template:
        "main" minmax(0, 1fr)
        / minmax(0, 1fr);
}

.page--splash .main {
    overflow: hidden;
}

.page--splash .content {
    max-width: none;
    height: 100%;
    padding: 0;
}

.splash {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    height: 100%;
    padding: 40px 24px calc(40px + env(safe-area-inset-bottom));
    text-align: center;
    background-color: var(--papier);
    background-image: url("/static/dahin/splash-bg.jpg");
    background-position: center;
    background-size: cover;
}

.splash > * {
    position: relative;
    z-index: 2;
}

.splash__roads {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
}

.splash__roads path {
    fill: none;
    stroke: rgb(var(--rgb-schwarz) / var(--o2));
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.splash__roads .splash__road--main {
    stroke: rgb(var(--rgb-schwarz) / var(--o3));
    stroke-width: 3.6;
}

.splash__logo {
    width: 76%;
    max-width: 320px;
    height: auto;
    filter: brightness(0);
    animation: logo-in 550ms ease-out both;
}

.splash__claim {
    max-width: 30ch;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
}

.splash__cta {
    margin-top: 12px;
}

.splash__rules {
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

@keyframes logo-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* --------------------------------------------------------------------------
   Golden Rules (onboarding) + about
   -------------------------------------------------------------------------- */

.rules__intro {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rule-list {
    display: flex;
    flex-direction: column;
    gap: 26px;
    margin-top: 30px;
}

.rule {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 18px;
    border-top: var(--line);
}

.rule__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--orange-dunkel);
}

.rule__text {
    font-size: 1rem;
    line-height: 1.55;
}

.rules__footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 36px;
    padding-top: 20px;
    border-top: var(--line);
}

.about__block {
    margin-top: 34px;
}

.about__block .lead + .lead {
    margin-top: 12px;
}

/* --------------------------------------------------------------------------
   Preferences
   -------------------------------------------------------------------------- */

.prefs__group {
    margin: 28px 0 0;
    padding: 0;
    border: 0;
}

.catgrid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

.catcard {
    position: relative;
    display: block;
    aspect-ratio: 331 / 221;
    overflow: hidden;
    border: var(--line);
    border-radius: var(--radius);
    background: var(--hell);
    cursor: pointer;
    transition: box-shadow 140ms ease;
}

.catcard__input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.catcard__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.catcard__label {
    position: absolute;
    top: 20px;
    left: 0;
    z-index: 1;
    padding: 4px 10px;
    border: 2.4px solid var(--schwarz);
    border-left: 0;
    background: var(--schwarz);
    color: var(--hell);
    font-size: 1.0625rem;
    letter-spacing: 0.03em;
}

.catcard__add {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: var(--line);
    border-radius: var(--radius);
    background: var(--hell);
    color: var(--orange);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.catcard:has(.catcard__input:checked) {
    box-shadow: 0 0 0 3px var(--orange);
}

.catcard:has(.catcard__input:checked) .catcard__add {
    background: var(--orange);
    color: var(--hell);
}

.catcard:has(.catcard__input:focus-visible) {
    outline: 3px solid var(--tinte);
    outline-offset: 3px;
}

.prefs__footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 32px;
}

/* --------------------------------------------------------------------------
   Legal pages
   -------------------------------------------------------------------------- */

.legal__block {
    margin-top: 28px;
    padding-top: 20px;
    border-top: var(--line);
}

.legal__title {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.2;
}

.legal__text {
    margin-top: 8px;
    max-width: 65ch;
    font-size: 1rem;
    line-height: 1.6;
}

.legal__link {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.legal__note {
    margin-top: 32px;
    padding: 16px;
    border: var(--border-width) solid var(--tinte);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-style: italic;
}

/* --------------------------------------------------------------------------
   Desktop: two columns (> 600px) and three columns (> 1024px)
   -------------------------------------------------------------------------- */

@media (width >= 600px) {
    body {
        padding: var(--frame-gap);
    }

    .shell {
        grid-template:
            "header main" auto
            "sidenav main" minmax(0, 1fr)
            / 200px minmax(0, 1fr);
        max-width: 1024px;
        height: calc(100dvh - 2 * var(--frame-gap));
        border: var(--border-width) solid var(--tinte);
        border-radius: var(--radius);
    }

    .tabbar {
        display: none;
    }

    .sidenav {
        grid-area: sidenav;
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 8px 0 24px;
        overflow-y: auto;
        border-top: var(--border-width) solid var(--tinte);
        background: var(--papier);
    }

    .sidenav__eyebrow {
        padding: 16px 20px 8px;
        font-size: 0.6875rem;
        font-weight: 500;
        letter-spacing: 0.14em;
        text-transform: uppercase;
        color: rgb(var(--rgb-schwarz) / var(--o6));
    }

    .sidenav__link {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 10px 20px;
        font-size: 0.9375rem;
        font-weight: 600;
        letter-spacing: 0.02em;
        text-decoration: none;
        border-left: 4px solid transparent;
    }

    .sidenav__link:hover {
        background: rgb(var(--rgb-schwarz) / var(--o1));
    }

    .sidenav__link.is-active {
        border-left-color: var(--orange);
        background: rgb(var(--rgb-schwarz) / var(--o1));
    }

    .catgrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .display {
        font-size: 3rem;
    }
}

@media (width >= 1024px) {
    body {
        padding: 32px;
    }

    .shell {
        grid-template:
            "header main aside" auto
            "sidenav main aside" minmax(0, 1fr)
            / 240px minmax(0, 1fr) 300px;
        max-width: 1400px;
        height: calc(100dvh - 64px);
    }

    .aside {
        grid-area: aside;
        display: flex;
        flex-direction: column;
        gap: 20px;
        padding: 24px 20px;
        overflow-y: auto;
        border-left: var(--border-width) solid var(--tinte);
        background: var(--hell);
    }

    .aside__card {
        padding: 16px;
        border: var(--line);
        border-radius: var(--radius);
        background: var(--papier);
    }

    .aside__title {
        font-family: var(--font-display);
        font-size: 1.125rem;
        font-weight: 400;
        letter-spacing: 0.02em;
        text-transform: uppercase;
    }

    .aside__text {
        margin-top: 8px;
        font-size: 0.9375rem;
        line-height: 1.5;
    }

    .aside__list {
        display: flex;
        flex-direction: column;
        gap: 2px;
        margin-top: 8px;
    }

    .aside__list a {
        display: flex;
        align-items: center;
        min-height: 44px;
        font-weight: 600;
        text-decoration: underline;
        text-underline-offset: 3px;
    }

    .aside__cta {
        margin-top: 14px;
    }

    .content {
        padding: 36px 40px 56px;
    }

    .catgrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* --------------------------------------------------------------------------
   Motion
   -------------------------------------------------------------------------- */

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

    .splash__logo {
        animation: none;
    }
}
