/* Goethify PWA - Papier-/Sepia-Theme (Farbwelt wie Android-App).
 * Seit 13.11.2026: Handschrift (Caveat) auf der gesamten Seite, nicht
 * nur bei den Überschriften - Caveat braucht dafür durchgängig größere
 * Schriftgrade als eine normale Grotesk. */

@font-face {
    font-family: 'Caveat';
    src: url('../fonts/caveat.ttf') format('truetype');
    font-display: swap;
}

:root {
    --paper-bg: #F2E8D5;
    --paper-card: #F8F0DE;
    --paper-white: #FDFAF0;
    --ink-primary: #3B2F23;
    --ink-secondary: #7A6647;
    --ochre-dark: #8A5A28;
    --ochre-soft: #E4C98C;
    --leather-dark: #4A3521;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper-bg);
    color: var(--ink-primary);
    font-family: 'Caveat', 'Comic Sans MS', cursive;
    font-size: 17px;
    line-height: 1.4;
}

body {
    padding: 12px 12px calc(72px + env(safe-area-inset-bottom, 0));
    max-width: 640px;
    margin: 0 auto;
    min-height: 100dvh;
}

/* Handschrift braucht rund 25 % groessere Grade als eine Grotesk */
p, li, label, button, select, textarea, .detail-text, .status { font-size: 1.3rem; }

.handwriting {
    font-family: 'Caveat', cursive;
    font-weight: 600;
    color: var(--leather-dark);
    margin: 0 0 10px;
    font-size: 1.8rem;
    line-height: 1.2;
}

.hidden { display: none !important; }

h3 { color: var(--leather-dark); margin: 18px 0 6px; font-size: 1.55rem; }
p { margin: 8px 0; }

/* ---- Karten ---- */
.card {
    background: var(--paper-card);
    border: 1px solid var(--ochre-soft);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 14px;
    box-shadow: 2px 3px 8px rgba(74, 53, 33, 0.12);
}

/* ---- Zitat-Banner ---- */
.quote-banner {
    display: flex;
    gap: 12px;
    align-items: center;
    background: linear-gradient(135deg, var(--paper-card), var(--ochre-soft));
    border: 1px solid var(--ochre-soft);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 14px;
}
.quote-bust { width: 64px; height: 64px; flex: 0 0 auto; }
.quote-text { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
#quote-text {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* ---- Eingabe ---- */
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row textarea { flex: 1; }
textarea {
    border: 1.5px solid var(--ochre-dark);
    border-radius: 10px;
    background: var(--paper-white);
    color: var(--ink-primary);
    padding: 10px;
    font: inherit;
    resize: vertical;
}
textarea:focus { outline: 2px solid var(--ochre-dark); }

/* ---- Mikrofon: eigene Zeile unter dem Textfeld, zentriert und groß ---- */
.mic-row { display: flex; justify-content: center; margin-top: 12px; }
.mic { width: 96px; height: 96px; color: var(--ochre-dark); }
.mic svg { width: 56px; height: 56px; }
.mic.recording {
    color: var(--paper-white);
    background: #8a2828;
    border-color: #8a2828;
    animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(138, 40, 40, 0.45); }
    50% { box-shadow: 0 0 0 10px rgba(138, 40, 40, 0); }
}

.hint { color: var(--ink-secondary); font-size: 1.15rem; }
.status { min-height: 1.3em; font-size: 1.2rem; color: var(--ochre-dark); }

/* ---- Schriftsteller ---- */
.writer-grid {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    flex-wrap: wrap;
}
.writer {
    flex: 1 1 60px;
    background: var(--paper-white);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 8px 4px;
    cursor: pointer;
    text-align: center;
    font: inherit;
    color: var(--ink-secondary);
    font-size: 1.15rem;
    transition: border-color 0.15s, transform 0.1s;
}
.writer img { width: 52px; height: 52px; display: block; margin: 0 auto 4px; }
.writer.selected {
    border-color: var(--ochre-dark);
    color: var(--leather-dark);
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(74, 53, 33, 0.2);
}

/* ---- Textlänge ---- */
.length-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
}
.length-mode {
    width: 64px;
    height: 48px;
    border: none;
    border-radius: 12px;
    background: var(--ochre-dark);
    color: var(--paper-white);
    display: grid;
    place-items: center;
    padding: 0;
}
/* Alle Zeichen in dieselbe Rasterzelle: genau eines ist sichtbar und sitzt mittig */
.length-mode > * { grid-area: 1 / 1; }
.length-mode:active { transform: translateY(1px); }
#length-equals { width: 30px; height: 30px; display: none; }
#length-down, #length-up { font-family: 'Caveat', cursive; font-size: 1.7rem; line-height: 1; }
#length-factor { font-family: 'Caveat', cursive; font-size: 1.6rem; font-weight: 600; }
#length-prohibition { width: 30px; height: 30px; display: none; }

/* ---- Buttons ---- */
button {
    font: inherit;
    cursor: pointer;
}
.primary {
    display: block;
    width: 100%;
    background: var(--ochre-dark);
    color: var(--paper-white);
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-size: 1.55rem;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(138, 90, 40, 0.35);
}
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: 0.6; cursor: wait; }

.secondary {
    background: var(--paper-white);
    color: var(--ink-primary);
    border: 1.5px solid var(--ochre-dark);
    border-radius: 10px;
    padding: 6px 14px;
}
.danger {
    background: transparent;
    color: #8a2828;
    border: 1.5px solid #8a2828;
    border-radius: 10px;
    padding: 6px 14px;
}
.link-btn {
    background: none;
    border: none;
    color: var(--ink-secondary);
    text-decoration: underline;
    padding: 6px 8px;
}
.icon-btn {
    background: var(--paper-white);
    border: 1.5px solid var(--ochre-dark);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:active { transform: scale(0.95); }

/* Lautsprecher neben dem Zitat: Material-/Android-Look, sepia-braun */
.quote-play { color: var(--ochre-dark); }
.quote-play svg { width: 22px; height: 22px; }

/* ---- Vortrag ---- */
#vortrag summary {
    cursor: pointer;
    font-family: 'Caveat', cursive;
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--leather-dark);
    list-style-position: inside;
}
.form-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 12px;
    align-items: center;
    margin-top: 10px;
}
.form-grid label { color: var(--ink-secondary); font-size: 1.3rem; }
select {
    border: 1.5px solid var(--ochre-dark);
    border-radius: 8px;
    background: var(--paper-white);
    color: var(--ink-primary);
    padding: 6px;
    font: inherit;
    font-size: 1.25rem;
}
input[type="checkbox"] { accent-color: var(--ochre-dark); width: 20px; height: 20px; flex: 0 0 auto; }

/* ---- Job-Preview ---- */
.job-progress {
    height: 10px;
    background: var(--paper-white);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--ochre-soft);
}
#job-bar {
    height: 100%;
    width: 0%;
    background: var(--ochre-dark);
    border-radius: 6px;
    transition: width 0.4s ease;
}

/* ---- Bibliothek ---- */
/* ---- Bibliotheks-Banner (wie in der Android-App) auf Bibliothek + Hilfe ---- */
.view-banner {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1.5px solid var(--ochre-soft);
    margin: 0 0 10px;
}
.view-heading { margin: 0 0 14px; }
.library-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.library-list li { margin-bottom: 10px; display: flex; gap: 8px; align-items: stretch; }
.library-list .lib-item { flex: 1; min-width: 0; }
.lib-item {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--paper-card);
    border: 1px solid var(--ochre-soft);
    border-radius: 12px;
    padding: 12px;
    font: inherit;
    color: var(--ink-primary);
    cursor: pointer;
}
.lib-item .lib-title { font-weight: 600; color: var(--leather-dark); font-size: 1.35rem; }
.lib-item .lib-meta { font-size: 1.1rem; color: var(--ink-secondary); margin-top: 4px; }
.lib-item .lib-speaker svg { width: 13px; height: 13px; vertical-align: -2px; }
.lib-item .lib-writing svg { width: 13px; height: 13px; vertical-align: -2px; }
/* Kleiner Download-Knopf am Listen-Eintrag (nur wenn Audio vorhanden) */
.lib-download {
    flex: 0 0 auto;
    align-self: center;
    background: var(--paper-card);
    border: 1px solid var(--ochre-soft);
    border-radius: 12px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-secondary);
    font: inherit;
}
.lib-download svg { width: 20px; height: 20px; }
.lib-download:active { transform: scale(0.95); }
.lib-download:hover { color: var(--ochre-dark); border-color: var(--ochre-dark); }

/* ---- Detail ---- */
.detail-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.detail-text {
    white-space: pre-wrap;
    background: var(--paper-white);
    border: 1px solid var(--ochre-soft);
    border-radius: 10px;
    padding: 12px;
    max-height: 46dvh;
    overflow-y: auto;
    font-size: 1.3rem;
    line-height: 1.45;
}
.audio-player { width: 100%; margin: 8px 0; }

/* ---- Tabbar ---- */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--paper-card);
    border-top: 1.5px solid var(--ochre-dark);
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 10;
}
.tabbar button {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 4px 6px;
    font-size: 1.1rem;
    color: var(--ink-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active {
    color: var(--ochre-dark);
    font-weight: 700;
    box-shadow: inset 0 3px 0 var(--ochre-dark);
}

/* ---- Install-Button ---- */
.install-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    background: var(--ochre-dark);
    color: var(--paper-white);
    border: none;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 0.85rem;
    z-index: 20;
    box-shadow: 0 3px 8px rgba(74, 53, 33, 0.3);
}

@media (min-width: 480px) {
    .writer img { width: 64px; height: 64px; }
}

/* ---- Einführungstour (Spotlight wie die Android-App) ---- */
.tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
}
.tour-hole {
    position: fixed;
    border-radius: 18px;
    border: 2.5px solid var(--ochre-soft);
    /* Riesiger Schlagschatten = halbtransparentes Lederbraun drumherum */
    box-shadow: 0 0 0 200vmax rgba(74, 53, 33, 0.75);
    pointer-events: none;
}
.tour-bubble {
    position: fixed;
    margin: 0;
    padding: 14px;
    z-index: 61;
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    animation: tour-fade 0.16s ease;
}
.tour-bubble.centered {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100vw - 32px));
}
.tour-bubble p { font-size: 1.3rem; margin: 4px 0 10px; }
.tour-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
@keyframes tour-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Tour deckt die Seite ab: keine Berührungen durchlassen */
.tour-overlay:not(.hidden) { touch-action: none; }

/* ---- Rechtslinks im Footer ---- */
.legal-footer {
    text-align: center;
    padding: 18px 16px 6px;
    font-size: 1.15rem;
    color: var(--ink-secondary);
}
.legal-footer a { color: var(--ochre-dark); text-decoration: none; }
.legal-footer a:hover, .legal-footer a:focus { text-decoration: underline; }
