/* VOS Druckerei — gleicher Look wie die quark_newspaper-NUI im Spiel:
   dunkles Leder/Holz für die Werkbank, Papier nur für die Seiten selbst. */

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

:root {
    --bg: #17110b;
    --bg-2: #241a10;
    --panel: #221a12;
    --field: #171109;
    --line: #4a3c2a;
    --line-soft: #2d2418;
    --ui: #e8dcc0;
    --ui-soft: #b8ab8c;
    --muted: #a99a78;
    --brass: #b49a68;
    --btn: #3a2e22;
    --btn-edge: #6b5a42;
    --red: #6d1f1f;
    --red-edge: #8d3b2f;
    --ok: #7d9a5a;
    --paper: #e9dcbe;
    --ink: #2a2018;
    --serif: Georgia, 'Times New Roman', serif;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    background: radial-gradient(120% 90% at 50% 20%, var(--bg-2), var(--bg) 70%) fixed;
    color: var(--ui); font-family: var(--serif); font-size: 15px;
}
[hidden] { display: none !important; }
h1, h2 { font-weight: bold; text-wrap: balance; margin: 0; }
a { color: inherit; }

/* ── Knöpfe & Felder ─────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-family: var(--serif); font-size: 15px; text-decoration: none;
    padding: 7px 16px; cursor: pointer;
    background: var(--btn); color: var(--ui);
    border: 1px solid var(--btn-edge); border-radius: 3px;
}
.btn:hover:not(:disabled) { background: #52432f; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.btn.primary { background: var(--red); border-color: var(--red-edge); }
.btn.primary:hover:not(:disabled) { background: #8a2a2a; }
.btn.ghost { background: transparent; color: var(--ui-soft); }
.btn.ghost:hover:not(:disabled) { background: rgba(255,255,255,.08); }
.btn.danger { color: #e0a090; border-color: #7a3a2c; }
.btn.small { font-size: 13px; padding: 4px 9px; }
.btn.nav { font-size: 20px; padding: 6px 18px; }

input[type=text], select, textarea {
    font-family: var(--serif); font-size: 15px;
    background: var(--field); color: #f0e6cc;
    border: 1px solid var(--line); border-radius: 3px; padding: 7px 10px;
}
.hint { font-size: 13px; color: var(--muted); line-height: 1.5; }
.hint b { color: var(--ui); font-weight: normal; font-family: 'Courier New', monospace; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.eyebrow, .doc-type { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--brass); }

/* ── Anmelde- und Meldeseite ─────────────────────────────────── */
.center {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 24px max(16px, env(safe-area-inset-left, 0px));
}
.card {
    width: min(460px, 100%); display: flex; flex-direction: column; gap: 14px;
    background: var(--panel); border: 1px solid var(--btn-edge); border-radius: 6px;
    padding: 30px 28px; box-shadow: 0 18px 40px rgba(0,0,0,.6);
}
.card h1 { font-size: 30px; }
.card p { margin: 0; line-height: 1.55; color: var(--ui-soft); }
.card .btn { align-self: flex-start; margin-top: 6px; }

/* ── Kopfzeile + Aufteilung ──────────────────────────────────── */
.bar {
    display: flex; align-items: center; gap: 14px;
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
    border-bottom: 1px solid var(--line); background: rgba(20,14,8,.7);
}
.brand { font-size: 20px; font-weight: bold; letter-spacing: .03em; }
.who { margin-left: auto; color: var(--ui-soft); font-style: italic; }
.layout {
    display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 18px;
    padding: 18px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
    max-width: 1500px; margin: 0 auto;
}
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }

/* ── Entwurfsliste ───────────────────────────────────────────── */
.drafts { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.aside-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.aside-head h2 { font-size: 18px; }
.doc-list { display: flex; flex-direction: column; gap: 6px; }
.doc-entry {
    display: flex; flex-direction: column; gap: 3px; text-align: left; cursor: pointer;
    font-family: var(--serif); color: var(--ui);
    background: var(--panel); border: 1px solid var(--line-soft); border-radius: 4px; padding: 10px 12px;
}
.doc-entry:hover { border-color: var(--btn-edge); }
.doc-entry.active { border-color: var(--brass); background: #2e2316; }
.doc-entry .t { font-size: 16px; font-weight: bold; overflow-wrap: anywhere; }
.doc-entry .m { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--brass); }
.dot.ingame { background: var(--ok); }

/* ── Editor ──────────────────────────────────────────────────── */
.panel {
    background: var(--panel); border: 1px solid var(--btn-edge); border-radius: 6px;
    box-shadow: 0 18px 40px rgba(0,0,0,.45); display: flex; flex-direction: column; min-width: 0;
}
.editor { min-height: 640px; }
.ed-head { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-head input { flex: 1; min-width: 200px; font-size: 19px; font-weight: bold; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--btn-edge); color: var(--ui-soft); white-space: nowrap; }
.chip.ingame { border-color: #5d7a3e; color: #c4dba3; }
.chip.waiting { border-color: #8a6c3f; color: #e2c58f; }
.ed-note { margin: 0; padding: 8px 18px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line-soft); line-height: 1.5; }
.ed-body { flex: 1; display: flex; min-height: 0; }
.ed-pages { width: 180px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.page-list { flex: 1; overflow-y: auto; max-height: 560px; }
.page-entry { padding: 9px 14px; font-size: 14px; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.page-entry:hover { background: #322817; }
.page-entry.active { background: #52432f; color: #fff; }
.page-actions { display: flex; gap: 5px; padding: 8px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.ed-form { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 14px 18px; min-width: 0; }
.form-row { display: flex; align-items: center; gap: 10px; font-size: 14px; flex-wrap: wrap; }
.form-text { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.form-text textarea { flex: 1; min-height: 320px; resize: vertical; line-height: 1.5; padding: 10px; }
.form-image { display: flex; flex-direction: column; gap: 10px; }
.ed-preview { width: 34%; min-width: 260px; border-left: 1px solid var(--line); display: flex; align-items: center; justify-content: center; padding: 14px; }
.preview-page {
    width: 100%; aspect-ratio: 10 / 13; overflow: hidden; border-radius: 4px; padding: 26px 24px;
    box-shadow: 0 8px 22px rgba(0,0,0,.5);
}
.preview-page .page-heading { font-size: 18px; }
.preview-page .page-body { font-size: 13px; }
.ed-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.foot-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.msg { font-size: 14px; color: var(--ui-soft); }
.msg.err { color: #f0a08c; }
.msg.ok { color: #c4dba3; }
@media (max-width: 1150px) {
    .ed-body { flex-direction: column; }
    .ed-pages { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .page-list { display: flex; flex-wrap: wrap; max-height: none; }
    .page-entry { border: 0; }
    .ed-preview { width: auto; border-left: 0; border-top: 1px solid var(--line); }
    .preview-page { max-width: 420px; }
}
.empty { display: flex; align-items: center; justify-content: center; min-height: 300px; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; }

/* ── Dialog ──────────────────────────────────────────────────── */
dialog { border: 1px solid var(--btn-edge); border-radius: 6px; padding: 0; background: var(--panel); color: var(--ui); max-width: min(440px, 92vw); width: 100%; }
dialog::backdrop { background: rgba(8,5,2,.7); }
.dlg { display: flex; flex-direction: column; gap: 8px; padding: 20px; }
.dlg h2 { font-size: 20px; margin-bottom: 6px; }
.dlg label { font-size: 13px; color: var(--ui-soft); margin-top: 4px; }
.dlg .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* ══ Papier und Seiten: identisch zur NUI (quark_newspaper/html/style.css) ══ */
.font-serif { font-family: Georgia, 'Times New Roman', serif; }
.font-hand  { font-family: 'Lugrasimo', cursive; }
.font-type  { font-family: 'Courier New', Courier, monospace; }

.page-inner, .sheet-face {
    background:
        radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.35), transparent 60%),
        repeating-linear-gradient(93deg, rgba(120,95,60,0.04) 0 2px, transparent 2px 5px),
        var(--paper);
    color: var(--ink);
}
.page-heading {
    font-size: 22px; font-weight: bold; text-align: center;
    border-bottom: 2px solid rgba(60,40,15,0.5); padding-bottom: 8px; margin-bottom: 14px; overflow-wrap: break-word;
}
.page-body { font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: break-word; hyphens: auto; text-align: justify; }
.page-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.page-inner.image-page { padding: 0 !important; background: #d9ccae; }
.inline-image { display: block; max-width: 100%; max-height: 45%; margin: 10px auto; border: 1px solid rgba(60,40,15,0.35); }
.page-inner.cover-page:not(.image-page) {
    background:
        radial-gradient(ellipse at 50% 25%, rgba(255,245,215,0.28), transparent 65%),
        repeating-linear-gradient(93deg, rgba(90,65,35,0.06) 0 2px, transparent 2px 6px),
        #d6c294;
    display: flex; flex-direction: column; justify-content: center; text-align: center; position: relative;
}
.page-inner.cover-page:not(.image-page)::before {
    content: ''; position: absolute; inset: 16px; border: 4px double rgba(90,60,25,0.55); border-radius: 4px; pointer-events: none;
}
.cover-page .page-heading { border-bottom: none; padding-bottom: 0; font-size: 30px; letter-spacing: 1px; margin-bottom: 18px; }
.cover-page .page-body { text-align: center; }
.preview-page.cover-page .page-heading { font-size: 21px; }

/* ── Leser ───────────────────────────────────────────────────── */
.reader {
    position: fixed; inset: 0; z-index: 50; overflow: hidden;
    background: rgba(10,8,5,.92);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    padding: 16px max(16px, env(safe-area-inset-left, 0px));
}
.reader-top { width: min(1050px, 92vw); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.reader-meta { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.doc-title { font-size: 22px; font-weight: bold; }
.reader-bottom { display: flex; align-items: center; gap: 18px; color: var(--ui-soft); font-variant-numeric: tabular-nums; }

.book {
    position: relative; width: min(1050px, 92vw); height: min(680px, 72vh);
    filter: drop-shadow(0 18px 30px rgba(0,0,0,0.55));
    transition: transform 0.65s ease-in-out; user-select: none; -webkit-user-select: none;
}
.page { position: absolute; top: 0; width: 50%; height: 100%; overflow: hidden; }
.page-left  { left: 0;  border-radius: 6px 0 0 6px; }
.page-right { left: 50%; border-radius: 0 6px 6px 0; }
.page .page-inner { width: 100%; height: 100%; padding: 34px 30px 44px 30px; overflow: hidden; }
.page-left .page-inner  { box-shadow: inset -22px 0 24px -18px rgba(60,40,15,0.55); }
.page-right .page-inner { box-shadow: inset 22px 0 24px -18px rgba(60,40,15,0.55); }
.page-num { position: absolute; bottom: 12px; width: 100%; text-align: center; font-size: 12px; color: #8a7350; }
.book.cover-centered { transform: translateX(-25%); }
.book.cover-view .page-left { visibility: hidden; }
.book.cover-view .page-right { border-radius: 6px; }
.book.cover-view .page-right .page-inner { box-shadow: inset 0 0 34px rgba(60,40,15,0.30); }

/* Umblättern (pageturn.js) */
.pt-layer { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.pt-page { position: absolute; left: 0; top: 0; transform-origin: 0 0; overflow: hidden; }
.pt-page .page-inner { width: 100%; height: 100%; padding: 34px 30px 44px 30px; overflow: hidden; }
.pt-l .page-inner { box-shadow: inset -22px 0 24px -18px rgba(60,40,15,0.55); }
.pt-r .page-inner { box-shadow: inset 22px 0 24px -18px rgba(60,40,15,0.55); }
.pt-ov { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.pt-backwrap { position: absolute; inset: 0; filter: drop-shadow(-2px 0 10px rgba(30,18,6,0.35)); }
.book.pt-fwd .page-right, .book.pt-back .page-left { visibility: hidden; }
.page-inner.none { background: none; box-shadow: none !important; }

/* Tagesblatt: ein Blatt mit Vorder- und Rückseite */
.sheet-wrap { width: min(520px, 88vw); height: min(680px, 72vh); perspective: 2000px; filter: drop-shadow(0 18px 30px rgba(0,0,0,0.55)); }
.sheet { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.65s ease-in-out; }
.sheet.flipped { transform: rotateY(180deg); }
.sheet-face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 4px; overflow: hidden; }
.sheet-back { transform: rotateY(180deg); }
.sheet-face .page-inner { width: 100%; height: 100%; padding: 36px 32px; overflow: hidden; }

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