/* ============================================================
   Protos Arché – gemeinsames Design-System
   ============================================================ */

:root {
    --grad-a: #667eea;
    --grad-b: #764ba2;
    --grad: linear-gradient(135deg, var(--grad-a) 0%, var(--grad-b) 100%);
    --ink: #2d2a3e;
    --ink-soft: #5a5670;
    --paper: #ffffff;
    --paper-soft: #f6f7fb;
    --line: #e4e6f0;
    --green: #0c8a3e;
    --green-bg: #e8f5e9;
    --blue: #1a56db;
    --blue-bg: #e3f2fd;
    --orange: #e07b00;
    --orange-bg: #fff3e0;
    --red: #dc143c;
    --red-bg: #ffe8ee;
    --radius: 14px;
    --shadow: 0 10px 40px rgba(45, 42, 78, 0.18);
    --body-grad: linear-gradient(135deg, var(--grad-a) 0%, var(--grad-b) 100%);
    --footer-bg: rgba(255, 255, 255, 0.94);
    --scroll-thumb: #c6c9de;
    --scroll-thumb-hover: #a8acce;
    --table-row-line: #f0f0f5;
}

/* ---------- Dunkler Modus (Umschalter in der Navigation) ---------- */

html[data-theme="dark"] {
    --ink: #e9e7f7;
    --ink-soft: #b4afd2;
    --paper: #232136;
    --paper-soft: #2b2843;
    --line: #3e3a5c;
    --green: #4ade80;
    --green-bg: rgba(74, 222, 128, 0.13);
    --blue: #82a5ff;
    --blue-bg: rgba(130, 165, 255, 0.13);
    --orange: #ffb45e;
    --orange-bg: rgba(255, 180, 94, 0.13);
    --red: #ff6584;
    --red-bg: rgba(255, 101, 132, 0.13);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
    --body-grad: linear-gradient(135deg, #1d1a33 0%, #2a1f45 100%);
    --footer-bg: rgba(29, 26, 48, 0.94);
    --scroll-thumb: #4a4668;
    --scroll-thumb-hover: #5d5882;
    --table-row-line: #363250;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

::selection {
    background: rgba(102, 126, 234, 0.3);
}

/* Dezente, zum Design passende Scrollbalken */
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-thumb-hover);
    background-clip: content-box;
    border: 2px solid transparent;
}

/* Sichtbarer Tastatur-Fokus */
button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(102, 126, 234, 0.5);
    outline-offset: 2px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--body-grad) fixed;
    min-height: 100vh;
    color: var(--ink);
    padding: 10px 20px 70px 20px;
}

/* ---------- Kopfzeile / Navigation ---------- */

.site-nav {
    max-width: 1240px;
    margin: 0 auto 10px auto;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    color: white;
}

.site-nav .brand {
    font-size: 1.25em;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.site-nav .brand .mark {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    font-size: 1.05em;
}

.site-nav .links {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-wrap: wrap;
}

.site-nav .links a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.95em;
    transition: background 0.2s, color 0.2s;
}

.site-nav .links a:hover {
    background: rgba(255, 255, 255, 0.16);
    color: white;
}

.site-nav .links a.active {
    background: rgba(255, 255, 255, 0.92);
    color: var(--grad-a);
}

.theme-toggle {
    width: 38px;
    height: 38px;
    min-width: 38px;
    padding: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-size: 1.05em;
    line-height: 1;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: none;
    box-shadow: none;
}

.lang-toggle {
    width: auto;
    min-width: 44px;
    padding: 0 11px;
    font-size: 0.85em;
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* ---------- Karten / Container ---------- */

.container {
    max-width: 1240px;
    margin: 0 auto;
    background: var(--paper);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 16px 28px 28px 28px;
    animation: containerIn 0.4s ease both;
}

@keyframes containerIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}

h1 {
    text-align: center;
    color: var(--ink);
    font-size: 1.65em;
    margin-bottom: 4px;
}

.subtitle {
    text-align: center;
    color: var(--ink-soft);
    margin-bottom: 14px;
    font-size: 0.95em;
}

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

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--ink-soft);
    font-size: 0.92em;
}

input[type="number"],
select {
    width: 100%;
    padding: 10px 13px;
    border: 2px solid var(--line);
    border-radius: 9px;
    font-size: 15px;
    background: var(--paper);
    color: var(--ink);
    transition: border-color 0.25s;
    font-family: inherit;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--grad-a);
}

button,
.btn {
    padding: 11px 18px;
    background: var(--grad);
    color: white;
    border: none;
    border-radius: 9px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover,
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 16px rgba(102, 126, 234, 0.45);
}

button:active,
.btn:active {
    transform: translateY(0);
}

button.ghost,
.btn.ghost {
    background: var(--paper);
    color: var(--grad-a);
    border: 2px solid var(--grad-a);
}

button.small {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 7px;
}

/* ---------- Umschalter (Toggle) ---------- */

.toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    color: var(--ink-soft);
}

.toggle input {
    display: none;
}

.toggle .track {
    width: 42px;
    height: 23px;
    background: #cfd2e3;
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle .track::after {
    content: '';
    position: absolute;
    top: 2.5px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: left 0.2s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.toggle input:checked + .track {
    background: var(--grad-a);
}

.toggle input:checked + .track::after {
    left: 21px;
}

/* ---------- Popup ---------- */

.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 16, 40, 0.66);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.popup-overlay.hidden {
    display: none;
}

.popup-content {
    background: var(--paper);
    border-radius: 16px;
    max-width: 1200px;
    width: 92%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
    animation: popupSlideIn 0.28s ease-out;
}

@keyframes popupSlideIn {
    from {
        transform: translateY(-40px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: var(--grad);
    border-radius: 16px 16px 0 0;
    position: sticky;
    top: 0;
    z-index: 5;
}

.popup-header h2 {
    color: white;
    font-size: 1.4em;
}

.popup-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 28px;
    color: white;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    line-height: 1;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.32);
    transform: none;
    box-shadow: none;
}

.popup-body {
    padding: 18px 22px 24px 22px;
}

/* ---------- Lade-Spinner ---------- */

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner-box {
    background: var(--paper);
    padding: 30px 44px;
    border-radius: 14px;
    text-align: center;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 56px;
    height: 56px;
    border: 6px solid var(--line);
    border-top-color: var(--grad-a);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 16px auto;
}

/* ---------- Fußzeile ---------- */

footer.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 11px;
    background: var(--footer-bg);
    border-top: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: 0.85em;
    z-index: 900;
    backdrop-filter: blur(6px);
}

footer.site-footer a {
    color: var(--grad-a);
    text-decoration: none;
}

.hidden {
    display: none !important;
}

/* Texte, die nur in einem Farbmodus gelten */
.dark-only {
    display: none;
}

html[data-theme="dark"] .dark-only {
    display: inline;
}

html[data-theme="dark"] .light-only {
    display: none;
}

/* ---------- Hover-Tooltips für Variablen ---------- */

[data-tip] {
    position: relative;
}

[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 9px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--paper);
    padding: 8px 12px;
    border-radius: 8px;
    width: max-content;
    max-width: 270px;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.55;
    text-align: left;
    white-space: normal;
    z-index: 600;
    pointer-events: none;
    box-shadow: 0 6px 22px rgba(20, 16, 48, 0.35);
    opacity: 0;
    animation: tipIn 0.18s ease 0.25s forwards;
}

[data-tip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--ink);
    z-index: 600;
    pointer-events: none;
    opacity: 0;
    animation: tipIn 0.18s ease 0.25s forwards;
}

@keyframes tipIn {
    to {
        opacity: 1;
    }
}

/* ---------- Brand: Δ-Logo mit Verlauf ---------- */

.site-nav .brand .mark {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.6);
}

.site-nav .brand .mark b {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
}

/* ---------- Hintergrund-Ornamente: große Dreieck-Konturen ---------- */

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='520' viewBox='0 0 600 520'%3E%3Cpath d='M300 20 L580 500 L20 500 Z' fill='none' stroke='white' stroke-width='3'/%3E%3C/svg%3E"),
        url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='520' viewBox='0 0 600 520'%3E%3Cpath d='M300 20 L580 500 L20 500 Z' fill='none' stroke='white' stroke-width='3'/%3E%3C/svg%3E");
    background-repeat: no-repeat, no-repeat;
    background-position: right -150px top -90px, left -230px bottom -170px;
    background-size: 660px 570px, 540px 470px;
    opacity: 0.07;
}

html[data-theme="dark"] body::before {
    opacity: 0.045;
}

/* ---------- Mini-Vorschauen auf der Startseite ---------- */

.card-mini {
    width: 100%;
    height: 116px;
    border-radius: 10px;
    background: var(--paper);
    border: 1px solid var(--line);
    display: block;
}

/* ---------- Startseite ---------- */

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 18px;
    margin-top: 22px;
}

.home-card {
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 26px 22px;
    text-decoration: none;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}

.home-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 28px rgba(102, 126, 234, 0.22);
    border-color: var(--grad-a);
}

.home-card h2 {
    font-size: 1.25em;
}

.home-card p {
    color: var(--ink-soft);
    line-height: 1.55;
    font-size: 0.95em;
    flex: 1;
}

.home-card .go {
    color: var(--grad-a);
    font-weight: 700;
    font-size: 0.95em;
}

@media (max-width: 768px) {
    body {
        padding: 8px 10px 70px 10px;
    }

    .container {
        padding: 18px 14px;
    }

    h1 {
        font-size: 1.6em;
    }
}

/* ---------- Variablen-Verzeichnis ---------- */

.var-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 7px 16px;
    margin: 12px 0 4px 0;
    align-items: baseline;
}

.var-list dt {
    font-family: 'Cascadia Code', Consolas, monospace;
    font-weight: 700;
    color: var(--grad-a);
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 9px;
    text-align: center;
    white-space: nowrap;
}

.var-list dd {
    margin: 0;
    color: var(--ink);
    line-height: 1.6;
}
