/* Basis-Styling für alle Seiten: Farben, Grundlayout, Kopf/Fuß, Buttons, Formulare,
   Hilfsklassen. Mobil zuerst gebaut: die Grundwerte gelten für kleine Bildschirme,
   größere Bildschirme ergänzen per min-width. */

:root {
    --color-primary: #3d5a52;
    --color-primary-hover: #2f4a43;
    --color-text: #4A2718;     /* wie Theravada-Plattform */
    --color-muted: #6B6355;       /* war #888 - zu wenig Kontrast auf hellem Grund */
    --color-bg: #FFFBF7;
    --color-card: #fff;
    --color-border: #D3D1C7;
    --color-chip: #F5F3F0;
    --color-chip-border: #DBCEC3;
    --color-chip-hover: #E9DFD6;
    --color-success: #1f7a37;
    --color-success-hover: #186a2e;
    --color-ai: #6f42c1;
    --color-ai-hover: #5a32a3;
    --color-neutral: #6b6b6b;
    --color-focus: #1a73e8;
    --color-accent: #B98E61;      /* Ocker, nur Zierde (zu wenig Kontrast für Text) */
    --color-link: #8A5A2E;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.15);
    --color-btn-border: #85705E;  /* Rand von Nebenknöpfen: 4,6:1 auf Seite und Weiß */
    --color-danger: #b3261e;      /* Löschen: 6,4:1 auf Weiß */
    --btn-shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 2px 5px rgba(0, 0, 0, 0.14);
    --btn-shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.3), 0 4px 9px rgba(0, 0, 0, 0.18);
    --tap-size: 44px;             /* Mindestgröße für Tippflächen auf dem Handy */
}

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

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

body {
    font-family: system-ui, sans-serif;
    line-height: 1.5;
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    overflow-wrap: break-word;
}

/* Hintergrund hinter dem Inhalt: ein leises Punktraster auf einem Farbverlauf. Reines CSS,
   keine Bilddatei (früher ein von Pexels nachgeladenes Foto - das fehlte offline und kostete
   Datenvolumen). Raster ändern: Abstand (22px) und Punktfarbe (rgba) in der ersten Zeile. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle, rgba(185, 142, 97, 0.22) 1.2px, transparent 1.6px) 0 0 / 22px 22px,
        linear-gradient(135deg, #FFFBF7 0%, #F5F3F0 100%);
    z-index: -1;
}

/* ---------- Barrierefreiheit: Fokus, Skip-Link, nur-für-Screenreader ---------- */

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

header :focus-visible {
    outline-color: #fff;
}

/* Skip-Link: unsichtbar, bis er per Tab den Fokus bekommt */
.skip-link:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link:focus {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1000;
    padding: 0.75rem 1rem;
    background: #fff;
    color: #000;
    border-radius: 6px;
    box-shadow: var(--shadow-hover);
}

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

main:focus {
    outline: none; /* Ziel des Skip-Links, soll keinen Rahmen zeigen */
}

.hidden {
    display: none !important;
}

ul.today-list,
ul.plain-list {
    list-style: none;
}

/* ---------- Kopf, Inhalt, Fuß ---------- */

header {
    background-color: var(--color-primary);
    color: #fff;
    padding: 1.5rem 1rem;
    text-align: center;
    border-bottom: 4px solid var(--color-accent);
}

header h1 {
    font-size: clamp(1.4rem, 5vw, 2rem);
    line-height: 1.25;
}

header p {
    margin-top: 0.5rem;
    opacity: 0.9;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap-size); /* ausreichend große Tippfläche */
    padding: 0 0.25rem;
    color: #fff;
    text-decoration: underline;
}

main {
    max-width: 1100px;
    margin: 1.25rem auto;
    padding: 0 max(0.75rem, env(safe-area-inset-right)) 0 max(0.75rem, env(safe-area-inset-left));
}

/* Lesebreite für Seiten mit viel Text */
.narrow-content {
    max-width: 700px;
}

footer {
    text-align: center;
    padding: 1rem 1rem 5rem; /* unten Platz für Offline-Hinweis und Nach-oben-Button */
    color: var(--color-muted);
    font-size: 0.85rem;
}

footer button {
    margin-top: 0.5rem;
}

.intro {
    text-align: center;
    color: #6B6355;
    margin-bottom: 1.25rem;
}

.hint {
    color: var(--color-muted);
    text-align: center;
    padding: 1.5rem 0;
}

.small-hint {
    color: var(--color-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

/* Meldungsfelder (Live-Bereiche), die erst nach einer Aktion Text bekommen: Leer nehmen sie keinen
   Platz ein, bleiben aber im Dokument. Mit display:none würden Screenreader die spätere Meldung
   oft nicht ansagen. */
[role="status"]:empty,
[role="alert"]:empty,
[aria-live]:empty {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Buttons, Formularfelder ---------- */

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--tap-size);
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 6px;
    background-color: var(--color-primary);
    color: #fff;
    font: inherit;
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
    /* Plastische Wirkung: feiner Schatten, damit Knöpfe als Knöpfe erkennbar sind */
    box-shadow: var(--btn-shadow);
    transition: box-shadow 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}

button:hover,
.button-link:hover {
    background-color: var(--color-primary-hover);
    box-shadow: var(--btn-shadow-hover);
    transform: translateY(-1px);
}

button:active,
.button-link:active {
    transform: translateY(0);
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.3);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Nebenaktionen in ruhigerer Farbe */
/* Rand 4,5:1 gegenüber Seite und Weiß (WCAG verlangt für Bedienelemente mindestens 3:1) */
.secondary-btn {
    background-color: #fff;
    color: var(--color-primary);
    border: 1.5px solid var(--color-btn-border);
}

.secondary-btn:hover {
    background-color: var(--color-chip-hover);
}

.neutral-btn {
    background-color: var(--color-neutral);
}

.neutral-btn:hover {
    background-color: #555;
}

/* Hauptaktionen (abschließen, starten) */
.primary-action {
    background-color: var(--color-success);
    font-size: 1rem;
    padding: 0.8rem 1.5rem;
}

.primary-action:hover {
    background-color: var(--color-success-hover);
}

/* "KI generiert etwas" ist app-weit gleich eingefärbt */
.ai-btn {
    background-color: var(--color-ai);
}

.ai-btn:hover {
    background-color: var(--color-ai-hover);
}

/* Schrift in Eingabefeldern mindestens 16px: sonst zoomt iOS beim Antippen die Seite heran */
input[type="text"],
input[type="search"],
input[type="password"],
select,
textarea {
    width: 100%;
    min-height: var(--tap-size);
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: #fff;
    color: var(--color-text);
    font: inherit;
    font-size: 1rem;
}

textarea {
    resize: vertical;
    margin-bottom: 0.5rem;
}

/* ---------- Code ---------- */

pre {
    background: #F5F3F0;
    color: var(--color-text);
    border: 1px solid #DBCEC3;
    padding: 0.85rem;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
    tab-size: 2;
    -webkit-overflow-scrolling: touch;
}

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

.block {
    background: var(--color-card);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.block h2 {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

/* ---------- Startseite: Kacheln ---------- */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
    gap: 1rem;
}

.card {
    display: block;
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--color-text);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.15s ease;
}

.card:hover {
    transform: translateY(-4px);
}

.card h2 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.offline-box {
    margin-top: 1.5rem;
}

/* ---------- Runder "Nach oben"-Button (js/scroll-top.js) ---------- */

.scroll-top-btn {
    position: fixed;
    bottom: max(1rem, env(safe-area-inset-bottom));
    right: max(1rem, env(safe-area-inset-right));
    width: 48px;
    height: 48px;
    min-height: 48px;
    border-radius: 50%;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    z-index: 100;
}

.scroll-top-btn svg {
    width: 22px;
    height: 22px;
}

/* ---------- Offline-Hinweis (js/common.js) ---------- */

.offline-banner {
    position: fixed;
    left: max(1rem, env(safe-area-inset-left));
    right: 5rem; /* lässt rechts Platz für den Nach-oben-Button */
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 99;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #5d4a00;
    font-size: 0.85rem;
    box-shadow: var(--shadow-hover);
}

/* Ausgeblendet, aber im Dokument: Screenreader sagen Änderungen weiterhin an, sobald Text erscheint */
.offline-banner.is-hidden {
    position: absolute;
    left: 0;
    right: auto;
    bottom: auto;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    white-space: nowrap;
}

.offline-banner.is-ok {
    background: #e8f5e9;
    border-color: #a5d6a7;
    color: #1b5e20;
}

/* ---------- Größere Bildschirme ---------- */

@media (min-width: 700px) {
    header {
        padding: 2rem 1rem;
    }

    main {
        margin: 2rem auto;
        padding: 0 2rem;
    }

    .block {
        padding: 1.25rem 1.5rem;
    }

    .card {
        padding: 1.5rem;
    }

    .offline-banner {
        right: auto;
        max-width: 28rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    button,
    .button-link {
        transition: none;
    }

    button:hover,
    .button-link:hover {
        transform: none;
    }

    .card {
        transition: none;
    }

    .card:hover {
        transform: none;
    }
}

/* ---------- Links im Fließtext: Braun wie auf der Theravada-Plattform ---------- */
main p a:not([class]),
main li a:not([class]),
main .hint a,
main .small-hint a {
    color: var(--color-link);
}

main p a:not([class]):hover,
main li a:not([class]):hover,
main .hint a:hover,
main .small-hint a:hover {
    color: var(--color-primary);
}
