/*
 * Trading-Tipps – „Finanz-Journal“
 * Serifen für Zahlen und Überschriften (Instrument Serif), klare Grotesk für alles andere (Schibsted Grotesk).
 * Dunkles Tintengrün als Standard, warmes Papier im hellen Modus. Bernstein als Akzent, Grün/Rot nur für Gewinn/Verlust.
 */

/* Schriften lokal (Open Font License, über AssetMapper ausgeliefert, kein externer Abruf) */
@font-face {
    font-family: 'Schibsted Grotesk';
    src: url("../fonts/schibsted-grotesk-latin-400-normal-m0jl8Xu.woff2") format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Schibsted Grotesk';
    src: url("../fonts/schibsted-grotesk-latin-500-normal-Qcro1VK.woff2") format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Schibsted Grotesk';
    src: url("../fonts/schibsted-grotesk-latin-600-normal-IjnPhol.woff2") format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Schibsted Grotesk';
    src: url("../fonts/schibsted-grotesk-latin-700-normal-90vFDgk.woff2") format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Instrument Serif';
    src: url("../fonts/instrument-serif-latin-400-normal-Mk_Cyu2.woff2") format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Instrument Serif';
    src: url("../fonts/instrument-serif-latin-400-italic-pXHJ7As.woff2") format('woff2');
    font-weight: 400;
    font-style: italic;
    font-display: swap;
}

:root {
    --font-display: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
    --font-body: 'Schibsted Grotesk', 'Avenir Next', 'Segoe UI', sans-serif;

    --bg: #0d1310;
    --bg-raised: #131b17;
    --bg-sunken: #0a0f0c;
    --line: #22302a;
    --line-strong: #33463d;
    --text: #e9eee6;
    --text-soft: #a7b4ab;
    --text-faint: #6f7f75;
    --accent: #e3a548;
    --accent-ink: #1a1206;
    --up: #5cc98e;
    --up-bg: rgba(92, 201, 142, .12);
    --down: #ef7666;
    --down-bg: rgba(239, 118, 102, .12);
    --focus: rgba(227, 165, 72, .45);
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 12px 30px -18px rgba(0, 0, 0, .7);
    --radius: 14px;
    --radius-small: 9px;
    --grain-opacity: .05;
    color-scheme: dark;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f4f0e6;
        --bg-raised: #fbf8f1;
        --bg-sunken: #ece6d8;
        --line: #ddd4c1;
        --line-strong: #c9bea6;
        --text: #1d211c;
        --text-soft: #555c52;
        --text-faint: #8a8e82;
        --accent: #b8741c;
        --accent-ink: #fffaf0;
        --up: #217a4a;
        --up-bg: rgba(33, 122, 74, .1);
        --down: #b6402f;
        --down-bg: rgba(182, 64, 47, .09);
        --focus: rgba(184, 116, 28, .35);
        --shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 10px 24px -18px rgba(60, 45, 20, .45);
        --grain-opacity: .06;
        color-scheme: light;
    }
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
        var(--bg);
    color: var(--text);
    font: 400 16px/1.55 var(--font-body);
}

/* Tabellenziffern nur in Zahlenfeldern: die Schrift macht sonst auch Satzzeichen gleich breit */
td.num, input[type="number"] {
    font-variant-numeric: tabular-nums lining-nums;
}

/* Papierkorn */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* ---------- Gerüst ---------- */

.shell {
    position: relative;
    z-index: 1;
    max-width: 980px;
    margin: 0 auto;
    padding: 20px 16px 110px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    border-bottom: 1px solid var(--line);
}

.topbar-inner {
    max-width: 980px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 1.45rem;
    letter-spacing: .01em;
}

.brand-mark {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
    transform: translateY(-2px);
}

.nav {
    display: flex;
    gap: 4px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    color: var(--text-soft);
    text-decoration: none;
    font-size: .93rem;
    transition: color .15s, background .15s;
}

.nav a:hover { color: var(--text); background: var(--bg-raised); }
.nav a[aria-current="page"] { color: var(--text); background: var(--bg-raised); box-shadow: inset 0 0 0 1px var(--line-strong); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .nav-quiet { display: none; }

@media (max-width: 720px) {
    .topbar .nav { display: none; }

    .bottom-nav {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
        z-index: 20;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        padding: 6px;
        border-radius: 20px;
        border: 1px solid var(--line-strong);
        background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
        backdrop-filter: blur(14px);
        box-shadow: 0 18px 40px -20px rgba(0, 0, 0, .7);
    }

    .bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 6px 0;
        border-radius: 14px;
        color: var(--text-faint);
        text-decoration: none;
        font-size: .72rem;
    }

    .bottom-nav a[aria-current="page"] { color: var(--text); background: var(--bg-sunken); }
    .bottom-nav a[aria-current="page"] svg { color: var(--accent); }
    .bottom-nav svg { width: 22px; height: 22px; }
}

@media (min-width: 721px) {
    .bottom-nav { display: none; }
    .nav .nav-quiet { display: flex; }
}

/* ---------- Typografie ---------- */

h1, h2, h3, .display {
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: .005em;
    line-height: 1.1;
}

h1 { font-size: clamp(2rem, 6vw, 2.8rem); margin: 8px 0 6px; }
h2 { font-size: 1.55rem; margin: 34px 0 12px; }
h3 { font-size: 1.2rem; margin: 0 0 6px; }

.eyebrow {
    margin: 0;
    color: var(--text-faint);
    font-size: .74rem;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.lede { color: var(--text-soft); margin: 0 0 22px; max-width: 60ch; }
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); font-size: .88rem; }

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 20px;
    margin-bottom: 18px;
}

.page-head .actions { margin: 0; }

/* ---------- Flächen ---------- */

.card {
    position: relative;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 14px;
}

.card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: border-color .18s, transform .18s;
}

.card-link:hover { border-color: var(--line-strong); transform: translateY(-1px); }

.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

/* Große Kennzahl */
.hero-figure {
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 10vw, 4rem);
    line-height: 1;
    margin: 4px 0 8px;
}

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin: 14px -18px -18px;
    border-top: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
}

/* Trennlinien an den Kacheln selbst, damit unvollständige Reihen keine Lücke zeigen */
.kpi {
    padding: 12px 18px;
    box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line);
}

.kpi .eyebrow { margin-bottom: 2px; }
.kpi-value { font-family: var(--font-display); font-size: 1.45rem; line-height: 1.15; }
.kpi-value .delta { font-family: var(--font-body); font-size: .86rem; }
.row-side > div:first-child { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.2; }

/* Gewinn/Verlust */
.tone-up { color: var(--up); }
.tone-down { color: var(--down); }
.tone-flat, .tone-none { color: var(--text-soft); }

.delta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: .86rem;
    font-weight: 600;
}

.delta.tone-up { background: var(--up-bg); }
.delta.tone-down { background: var(--down-bg); }
.delta.tone-flat, .delta.tone-none { background: var(--bg-sunken); }

/* Chips und Badges */
.chip, .badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    color: var(--text-soft);
    font-size: .78rem;
    white-space: nowrap;
}

.chip-accent { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); }
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge::before { content: none; }

/* Antippbares Badge mit Erklärung (Popover) */
.chip-help { background: none; font: inherit; font-size: .78rem; cursor: pointer; }
.chip-help:hover, .chip-help:focus-visible { background: color-mix(in srgb, currentColor 10%, transparent); }
.chip-help-mark {
    display: inline-grid;
    place-items: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid currentColor;
    font-size: .62rem;
    font-weight: 700;
    line-height: 1;
}

.help-popover {
    width: min(26rem, calc(100vw - 32px));
    margin: auto;
    padding: 18px 18px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--bg-raised);
    color: var(--text);
    box-shadow: var(--shadow);
    white-space: normal;
}
.help-popover::backdrop { background: color-mix(in srgb, var(--bg) 55%, transparent); }
.help-popover p { margin: 8px 0 14px; color: var(--text-soft); line-height: 1.5; }

/* Stärke-Balken */
.meter {
    height: 4px;
    border-radius: 99px;
    background: var(--bg-sunken);
    overflow: hidden;
    margin-top: 12px;
}

.meter > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 55%, transparent), var(--accent));
}

/* Listen */
.rows { list-style: none; margin: 0; padding: 0; }

.rows > li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.rows > li:last-child { border-bottom: 0; }
.row-main { min-width: 0; }
.row-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { text-align: right; flex: none; }

.reasons { margin: 10px 0 0; padding: 0; list-style: none; }
.reasons li { padding: 6px 0 0; color: var(--text-soft); font-size: .93rem; }
.reasons strong { color: var(--text); font-weight: 600; }

/* Tabellen */
.table-scroll { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th { text-align: left; font-weight: 500; color: var(--text-faint); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; padding: 0 10px 8px 0; }
td { padding: 10px 10px 10px 0; border-top: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 22px; margin: 0; }
dl.facts dt { color: var(--text-faint); }
dl.facts dd { margin: 0; }

/* Reiter */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin: 0 0 18px;
    border-radius: 999px;
    background: var(--bg-sunken);
    border: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs a {
    flex: 1 0 auto;
    text-align: center;
    padding: 8px 14px;
    border-radius: 999px;
    color: var(--text-soft);
    text-decoration: none;
    font-size: .92rem;
    white-space: nowrap;
}

.tabs a[aria-current="page"] { background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow), inset 0 0 0 1px var(--line-strong); }
.tabs .short { display: none; }

@media (max-width: 480px) {
    .tabs a { padding: 7px 10px; font-size: .84rem; }
    .tabs .long { display: none; }
    .tabs .short { display: inline; }
}

.tabs .count { display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; }

/* Aufklappbare Bereiche */
details.drawer {
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    margin-bottom: 14px;
    background: color-mix(in srgb, var(--bg-raised) 50%, transparent);
}

details.drawer[open] { border-style: solid; background: var(--bg-raised); }

details.drawer > summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary::after { content: '+'; font-family: var(--font-display); font-size: 1.5rem; color: var(--accent); line-height: 1; transition: transform .2s; }
details.drawer[open] > summary::after { transform: rotate(45deg); }
details.drawer > .drawer-body { padding: 0 18px 18px; }

/* Kursverlauf */
.sparkline { display: block; width: 100%; height: 56px; margin: 12px 0 4px; overflow: visible; }
.sparkline-line { fill: none; stroke: var(--text-soft); stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.sparkline-up .sparkline-line { stroke: var(--up); }
.sparkline-down .sparkline-line { stroke: var(--down); }
.sparkline-area { stroke: none; fill: currentColor; opacity: .08; }
.sparkline-up { color: var(--up); }
.sparkline-down { color: var(--down); }
.sparkline-high { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; opacity: .8; }
.sparkline-dot { fill: var(--accent); }
.row-main .sparkline { height: 34px; margin: 6px 0 0; max-width: 220px; }

/* News */
details.news { border-style: solid; }
details.news > summary { padding: 10px 14px; font-size: .9rem; }
details.news > .drawer-body { padding: 0 14px 14px; }
details.insider .reasons li { line-height: 1.45; }

/* Externe Infolinks */
.ext-links { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; font-size: .82rem; }
.ext-links a { color: var(--text-faint); text-decoration: none; border-bottom: 1px dotted var(--line-strong); }
.ext-links a::after { content: ' ↗'; font-size: .75em; }
.ext-links a:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Formulare ---------- */

.field { margin-bottom: 16px; }
.field > label, .field > legend { display: block; margin-bottom: 6px; font-size: .86rem; font-weight: 600; color: var(--text-soft); }
.field-help { margin-top: 5px; font-size: .82rem; color: var(--text-faint); }
.field-errors { margin: 6px 0 0; padding: 0; list-style: none; color: var(--down); font-size: .85rem; }
.field-errors li::before { content: '↳ '; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
input:not([type]), select, textarea {
    width: 100%;
    padding: 11px 13px;
    font: inherit;
    color: var(--text);
    background: var(--bg-sunken);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-small);
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
textarea { min-height: 90px; resize: vertical; }

.choice-list { display: grid; gap: 8px; }
.choice-list label {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-small);
    background: var(--bg-sunken);
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
}
.choice-list label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice-list input { margin-top: 4px; accent-color: var(--accent); }

.check { display: flex; align-items: center; gap: 10px; font-size: .93rem; color: var(--text-soft); }
.check input { accent-color: var(--accent); width: 18px; height: 18px; }

.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- Knöpfe ---------- */

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.actions form { margin: 0; }

.btn, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-ink);
    font: 600 .95rem/1.2 var(--font-body);
    text-decoration: none;
    cursor: pointer;
    transition: filter .15s, transform .1s, background .15s;
}

.btn:hover, button:hover { filter: brightness(1.07); }
.btn:active, button:active { transform: translateY(1px); }

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line-strong);
}

.btn-ghost:hover { background: var(--bg-raised); filter: none; }

.btn-quiet {
    background: transparent;
    color: var(--text-soft);
    padding-inline: 10px;
}

.btn-quiet:hover { color: var(--text); filter: none; }
.btn-small { padding: 6px 13px; font-size: .85rem; }
.btn-block { width: 100%; }

/* ---------- Meldungen ---------- */

.flash {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: var(--radius-small);
    border: 1px solid var(--line-strong);
    background: var(--bg-raised);
    animation: rise .35s ease both;
}

.flash::before { content: ''; flex: none; width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: var(--text-soft); }
.flash-success::before { background: var(--up); }
.flash-error { border-color: color-mix(in srgb, var(--down) 50%, var(--line-strong)); }
.flash-error::before { background: var(--down); }

.empty {
    padding: 34px 20px;
    text-align: center;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    color: var(--text-soft);
}

.empty .display { font-size: 1.5rem; color: var(--text); margin-bottom: 6px; }

/* ---------- Einzelne Seiten ---------- */

.auth {
    min-height: 80vh;
    display: grid;
    place-items: center;
}

.auth .card { width: min(420px, 100%); padding: 28px; }
.auth h1 { margin-top: 0; }

.qr { display: inline-block; padding: 14px; background: #fff; border-radius: var(--radius); }
.qr img { display: block; width: 220px; height: 220px; }
code { font-size: .9em; padding: 2px 6px; border-radius: 6px; background: var(--bg-sunken); }
code.secret { word-break: break-all; }

/* ---------- Bewegung ---------- */

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

main > * { animation: rise .45s cubic-bezier(.2, .7, .2, 1) both; }
main > *:nth-child(2) { animation-delay: .04s; }
main > *:nth-child(3) { animation-delay: .08s; }
main > *:nth-child(4) { animation-delay: .12s; }
main > *:nth-child(5) { animation-delay: .16s; }
main > *:nth-child(n+6) { animation-delay: .2s; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
