/* =========================================================================
   Shoka — La Biblioteca de Furan
   A grimoire-dark, candle-lit, gold-foil magical library aesthetic.
   ========================================================================= */

:root {
    --ink:        #0a0712;   /* near-black aubergine night */
    --ink-2:      #140d22;
    --parchment:  #efe2c4;
    --parch-dim:  #c9b88f;
    --gold:       #d9b25a;
    --gold-bright:#f4d98a;
    --gold-deep:  #8a6a2f;
    --emerald:    #5fd0a0;
    --ember:      #e6913c;
    --violet:     #7d5bd1;
    --rune:       #b59ae8;
    --line:       rgba(217, 178, 90, 0.22);
    --glow-gold:  0 0 22px rgba(217, 178, 90, 0.30);
    --serif:      'EB Garamond', Georgia, serif;
    --display:    'Cinzel', serif;
    --display-2:  'Cinzel Decorative', serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--serif);
    font-size: 18px;
    color: var(--parchment);
    background:
        radial-gradient(1200px 700px at 50% -10%, #221640 0%, transparent 60%),
        radial-gradient(900px 600px at 85% 110%, #1a2433 0%, transparent 55%),
        radial-gradient(700px 500px at 10% 90%, #2a1330 0%, transparent 55%),
        linear-gradient(180deg, var(--ink-2), var(--ink) 70%);
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden;
}

/* drifting starfield + candle vignette ----------------------------------- */
.stars {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background-image:
        radial-gradient(1.4px 1.4px at 20% 30%, rgba(255,245,210,.9), transparent),
        radial-gradient(1.2px 1.2px at 70% 20%, rgba(214,196,255,.7), transparent),
        radial-gradient(1.6px 1.6px at 40% 70%, rgba(255,236,190,.6), transparent),
        radial-gradient(1px 1px at 85% 60%, rgba(255,255,255,.6), transparent),
        radial-gradient(1.3px 1.3px at 55% 45%, rgba(180,210,255,.5), transparent),
        radial-gradient(1px 1px at 12% 80%, rgba(255,255,255,.5), transparent);
    background-repeat: repeat;
    background-size: 600px 600px;
    opacity: .55;
    animation: drift 120s linear infinite;
}
@keyframes drift { from { background-position: 0 0; } to { background-position: 600px 400px; } }

.vignette {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    box-shadow: inset 0 0 320px 60px rgba(0,0,0,.85);
}

main, header, footer { position: relative; z-index: 1; }

a { color: var(--gold-bright); text-decoration: none; }
a:hover { color: #fff; }

/* === Header / brand ===================================================== */
.grimoire-header {
    display: flex; align-items: center; gap: 1.4rem;
    padding: 1.2rem clamp(1rem, 4vw, 3rem);
    flex-wrap: wrap;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(10,7,18,.7), transparent);
    backdrop-filter: blur(2px);
}
.brand { display: flex; align-items: center; gap: .9rem; }
.brand-sigil {
    font-size: 2.2rem; color: var(--gold);
    text-shadow: var(--glow-gold); animation: pulse 4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .8; } 50% { opacity: 1; text-shadow: 0 0 30px rgba(244,217,138,.6); } }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title {
    font-family: var(--display-2); font-weight: 900;
    font-size: clamp(1.2rem, 2.6vw, 1.9rem);
    background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, #9c7a36);
    -webkit-background-clip: text; background-clip: text; color: transparent;
    letter-spacing: .5px;
}
.brand-sub { font-size: .82rem; color: var(--parch-dim); letter-spacing: 1.5px; text-transform: uppercase; }

.search { display: flex; flex: 1 1 320px; max-width: 560px; }
.search input {
    flex: 1; padding: .7rem 1rem; font-family: var(--serif); font-size: 1rem;
    color: var(--parchment); background: rgba(20,13,34,.7);
    border: 1px solid var(--line); border-right: none;
    border-radius: 999px 0 0 999px; outline: none;
}
.search input::placeholder { color: #8c7fa6; font-style: italic; }
.search input:focus { box-shadow: inset 0 0 12px rgba(125,91,209,.4); border-color: var(--gold); }
.search button {
    padding: 0 1.2rem; font-size: 1.4rem; cursor: pointer; color: var(--ink);
    background: linear-gradient(180deg, var(--gold-bright), var(--gold));
    border: 1px solid var(--gold); border-radius: 0 999px 999px 0;
}
.conjure { display: flex; align-items: center; gap: .6rem; }
.inline { display: inline; }

/* === Buttons =========================================================== */
.btn {
    font-family: var(--display); font-size: .82rem; letter-spacing: .8px;
    padding: .6rem 1.1rem; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--line); background: rgba(20,13,34,.6);
    color: var(--parchment); transition: .18s ease; display: inline-block;
}
.btn:hover { transform: translateY(-1px); color: #fff; }
.btn-arcane {
    color: var(--ink); border-color: var(--gold);
    background: linear-gradient(180deg, var(--gold-bright), var(--gold) 70%, #b88e3e);
    box-shadow: var(--glow-gold);
}
.btn-arcane:hover { color: var(--ink); box-shadow: 0 0 28px rgba(244,217,138,.55); }
.btn-ghost:hover { border-color: var(--gold); box-shadow: var(--glow-gold); }
.btn-danger { border-color: rgba(220,90,90,.5); color: #f0a5a5; }
.btn-danger:hover { background: rgba(120,30,30,.5); color: #fff; }
.btn.big { padding: .85rem 1.6rem; font-size: 1rem; }

/* === Main scroll ======================================================= */
.scroll { padding: clamp(1.2rem, 4vw, 2.6rem) clamp(1rem, 5vw, 3.2rem) 4rem; max-width: 1400px; margin: 0 auto; }

.ledger { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.ledger-orb {
    font-family: var(--display); font-size: .9rem; letter-spacing: .5px;
    padding: .5rem 1.1rem; border-radius: 999px;
    border: 1px solid var(--line); background: rgba(20,13,34,.5); color: var(--parch-dim);
}
.ledger-orb.ember { color: var(--ember); border-color: rgba(230,145,60,.35); }
.view-toggle { margin-left: auto; display: inline-flex; gap: .3rem; }
.vt {
    font-family: var(--display); font-size: .78rem; letter-spacing: .5px;
    padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--line);
    color: var(--parch-dim); background: rgba(20,13,34,.4);
}
.vt:hover { border-color: var(--gold); color: var(--parchment); }
.vt.on { color: var(--ink); background: linear-gradient(180deg, var(--gold-bright), var(--gold)); border-color: var(--gold); box-shadow: var(--glow-gold); }

/* Table view (no covers) */
.grimoire-table {
    width: 100%; border-collapse: collapse; font-size: .98rem;
    background: rgba(20,13,34,.4); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.grimoire-table thead th {
    text-align: left; padding: .8rem 1rem; font-family: var(--display); font-size: .72rem;
    text-transform: uppercase; letter-spacing: 1.5px; color: var(--gold);
    border-bottom: 1px solid var(--line); background: rgba(34,22,58,.5);
}
.grimoire-table tbody tr { cursor: pointer; transition: .12s; border-bottom: 1px solid rgba(217,178,90,.1); }
.grimoire-table tbody tr:hover { background: rgba(125,91,209,.14); }
.grimoire-table td { padding: .65rem 1rem; color: var(--parch-dim); vertical-align: middle; }
.grimoire-table .t-title { color: var(--parchment); font-weight: 500; font-size: 1.02rem; }
.grimoire-table .t-type { font-family: var(--display); font-size: .8rem; color: var(--gold); white-space: nowrap; text-transform: capitalize; }
.grimoire-table .t-series { color: var(--rune); font-size: .9rem; }
.grimoire-table .t-author { font-style: italic; font-size: .9rem; }
.t-state { font-family: var(--display); font-size: .8rem; }
.t-state.emerald { color: var(--emerald); }
.t-state.ember { color: var(--ember); white-space: nowrap; }
@media (max-width: 680px) {
    .grimoire-table .t-author, .grimoire-table thead th:nth-child(4) { display: none; }
}

/* === Filters =========================================================== */
.filters { display: flex; flex-direction: column; gap: .7rem; margin-bottom: 2rem;
    padding-bottom: 1.4rem; border-bottom: 1px solid var(--line); }
.filter-group { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.filter-label { font-family: var(--display); font-size: .72rem; text-transform: uppercase;
    letter-spacing: 1.5px; color: var(--gold); min-width: 80px; }
.chip {
    font-size: .9rem; padding: .32rem .9rem; border-radius: 999px;
    border: 1px solid var(--line); color: var(--parch-dim);
    background: rgba(20,13,34,.4); transition: .15s; text-transform: capitalize;
}
.chip:hover { border-color: var(--gold); color: var(--parchment); }
.chip.on { color: var(--ink); background: linear-gradient(180deg, var(--gold-bright), var(--gold));
    border-color: var(--gold); box-shadow: var(--glow-gold); }
.chip.emerald.on { background: linear-gradient(180deg, #8ff0c5, var(--emerald)); border-color: var(--emerald); }
.chip.ember.on { background: linear-gradient(180deg, #ffc080, var(--ember)); border-color: var(--ember); }
.filters select {
    font-family: var(--serif); font-size: .95rem; padding: .4rem .8rem; color: var(--parchment);
    background: rgba(20,13,34,.7); border: 1px solid var(--line); border-radius: 8px;
}

/* === The shelf (grid of tomes) ========================================= */
.shelf {
    display: grid; gap: 1.6rem;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.tome {
    display: flex; flex-direction: column; border-radius: 12px; overflow: hidden;
    background: linear-gradient(165deg, rgba(34,22,58,.65), rgba(14,9,24,.85));
    border: 1px solid var(--line); transition: .22s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.tome:hover {
    transform: translateY(-6px); border-color: var(--gold);
    box-shadow: 0 14px 38px rgba(0,0,0,.55), var(--glow-gold);
}
.tome-cover { position: relative; aspect-ratio: 2/3; overflow: hidden; background: #0c0818; }
.tome-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tome-spine {
    width: 100%; height: 100%; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: .6rem; padding: 1rem; text-align: center;
    background:
        repeating-linear-gradient(90deg, rgba(217,178,90,.06) 0 6px, transparent 6px 14px),
        linear-gradient(160deg, #2a1d4d, #160e2b);
    border-right: 3px solid rgba(217,178,90,.3);
}
.tome-spine .rune { font-size: 2.4rem; filter: drop-shadow(0 0 8px rgba(181,154,232,.6)); }
.spine-title { font-family: var(--display); font-size: .9rem; color: var(--parch-dim); line-height: 1.25; }
.tome-spine.big { aspect-ratio: 2/3; min-height: 380px; }
.tome-spine.big .rune { font-size: 4rem; }

.seal {
    position: absolute; bottom: .5rem; left: .5rem; right: .5rem;
    font-family: var(--display); font-size: .68rem; letter-spacing: .5px;
    padding: .28rem .5rem; border-radius: 6px; text-align: center;
    backdrop-filter: blur(4px); border: 1px solid;
}
.seal.emerald { background: rgba(20,60,45,.78); color: #9ff0cd; border-color: rgba(95,208,160,.5); }
.seal.ember   { background: rgba(70,40,12,.82); color: #ffcf95; border-color: rgba(230,145,60,.55); }

.tome-meta { padding: .8rem .9rem 1rem; display: flex; flex-direction: column; gap: .25rem; }
.tome-type { font-family: var(--display); font-size: .66rem; text-transform: uppercase;
    letter-spacing: 1px; color: var(--gold); }
.tome-title { margin: .1rem 0; font-size: 1.08rem; font-weight: 500; line-height: 1.2; color: var(--parchment); }
.tome-author { margin: 0; font-size: .9rem; color: var(--parch-dim); font-style: italic; }
.tome-series { margin: .15rem 0 0; font-size: .78rem; color: var(--rune); letter-spacing: .5px; }
.is-lent .tome-cover { filter: saturate(.8); }

.empty { text-align: center; color: var(--parch-dim); font-size: 1.2rem; font-style: italic; padding: 4rem 1rem; }

/* === Detail / codex ==================================================== */
.back { font-family: var(--display); font-size: .82rem; letter-spacing: .5px; color: var(--parch-dim); }
.back:hover { color: var(--gold-bright); }

.codex { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 2.6rem; margin-top: 1.4rem; }
.codex-cover img, .codex-cover .tome-spine { width: 100%; border-radius: 12px;
    box-shadow: 0 14px 40px rgba(0,0,0,.6), var(--glow-gold); border: 1px solid var(--line); }
.status-banner {
    margin-top: 1rem; padding: .8rem 1rem; border-radius: 10px; text-align: center;
    font-family: var(--display); font-size: .9rem; border: 1px solid;
}
.status-banner small { font-family: var(--serif); opacity: .85; }
.status-banner.emerald { background: rgba(20,60,45,.5); color: #9ff0cd; border-color: rgba(95,208,160,.45); }
.status-banner.ember { background: rgba(70,40,12,.55); color: #ffcf95; border-color: rgba(230,145,60,.5); }

.codex-type { font-family: var(--display); font-size: .8rem; text-transform: uppercase;
    letter-spacing: 2px; color: var(--gold); }
.codex-title { font-family: var(--display-2); font-weight: 700; font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin: .3rem 0 .2rem; line-height: 1.1;
    background: linear-gradient(180deg, var(--gold-bright), var(--gold) 60%, #9c7a36);
    -webkit-background-clip: text; background-clip: text; color: transparent; }
.codex-author { font-style: italic; font-size: 1.2rem; color: var(--parch-dim); margin: 0 0 1.4rem; }
.codex-stats { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.4rem; margin: 0 0 1.4rem; }
.codex-stats dt { font-family: var(--display); font-size: .78rem; text-transform: uppercase;
    letter-spacing: 1px; color: var(--gold); align-self: center; }
.codex-stats dd { margin: 0; color: var(--parchment); }
.codex-notes { font-size: 1.05rem; line-height: 1.6; color: var(--parch-dim);
    border-left: 2px solid var(--line); padding-left: 1rem; font-style: italic; }

/* === Rituals (admin) =================================================== */
.rite { margin-top: 2rem; padding: 1.4rem; border-radius: 12px;
    border: 1px solid var(--line); background: rgba(20,13,34,.45); }
.rite-title { font-family: var(--display); font-size: 1rem; letter-spacing: 1px; color: var(--gold); margin: 0 0 1rem; }
.cover-paste {
    display: flex; flex-direction: column; align-items: center; gap: .5rem;
    padding: 1.1rem; margin-bottom: 1.2rem; text-align: center;
    border: 1px dashed var(--gold); border-radius: 10px;
    background: rgba(125,91,209,.08); transition: .2s;
}
.cover-paste.armed, .cover-paste:hover { background: rgba(125,91,209,.16); box-shadow: inset 0 0 16px rgba(125,91,209,.25); }
.cover-paste .cp-icon { font-size: 1.6rem; }
.cp-actions { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.cover-paste p { margin: 0; font-size: .95rem; color: var(--parch-dim); }
.cover-paste kbd {
    font-family: var(--display); font-size: .72rem; padding: .1rem .45rem;
    border: 1px solid var(--line); border-radius: 5px; background: rgba(10,7,18,.6); color: var(--gold-bright);
}
.cp-status { font-size: .85rem; color: var(--gold-bright); font-style: italic; min-height: 1em; }
.rite-row { display: flex; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.rite-form.lend { display: flex; flex-direction: column; gap: .6rem; padding: 1rem;
    border: 1px dashed var(--line); border-radius: 10px; }
.rite-form.lend h3 { margin: 0; font-family: var(--display); font-size: .95rem; color: var(--ember); }
.rite-form input { padding: .6rem .8rem; font-family: var(--serif); color: var(--parchment);
    background: rgba(10,7,18,.7); border: 1px solid var(--line); border-radius: 8px; }
.rite-form label { font-size: .85rem; color: var(--parch-dim); }

.annals { margin-top: 1.6rem; }
.annals summary { font-family: var(--display); font-size: .9rem; color: var(--gold); cursor: pointer; }
.annals ul { list-style: none; padding: .8rem 0 0; margin: 0; }
.annals li { padding: .4rem 0; border-bottom: 1px dotted var(--line); font-size: .95rem; color: var(--parch-dim); }
.annals .ember { color: var(--ember); }

/* === Scriptorium (forms) =============================================== */
.scriptorium { max-width: 760px; margin: 1.4rem auto 0; }
.scriptorium-title { font-family: var(--display-2); font-weight: 700; font-size: 2rem;
    text-align: center; color: var(--gold-bright); margin-bottom: 1.6rem; }
.conjure-isbn { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
    padding: 1rem; margin-bottom: 1.6rem; border-radius: 10px;
    border: 1px dashed var(--gold); background: rgba(125,91,209,.1); }
.conjure-isbn input { flex: 1 1 220px; padding: .6rem .9rem; font-family: var(--serif);
    color: var(--parchment); background: rgba(10,7,18,.6); border: 1px solid var(--line); border-radius: 8px; }
#conjure_status { font-size: .85rem; color: var(--gold-bright); font-style: italic; }
.scriptorium-form { display: flex; flex-direction: column; gap: 1rem; }
.scriptorium-form label { display: flex; flex-direction: column; gap: .35rem;
    font-family: var(--display); font-size: .76rem; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); }
.scriptorium-form input, .scriptorium-form select, .scriptorium-form textarea {
    padding: .7rem .9rem; font-family: var(--serif); font-size: 1rem; color: var(--parchment);
    background: rgba(10,7,18,.6); border: 1px solid var(--line); border-radius: 8px; }
.scriptorium-form input:focus, .scriptorium-form textarea:focus, .scriptorium-form select:focus {
    outline: none; border-color: var(--gold); box-shadow: inset 0 0 10px rgba(125,91,209,.3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.scriptorium-actions { text-align: center; margin-top: 1rem; }

/* === Gate (login) ===================================================== */
.gate { max-width: 420px; margin: 4rem auto; text-align: center;
    padding: 2.4rem; border-radius: 16px; border: 1px solid var(--gold);
    background: linear-gradient(165deg, rgba(34,22,58,.7), rgba(14,9,24,.9)); box-shadow: var(--glow-gold); }
.gate-sigil { font-size: 3.4rem; color: var(--gold); text-shadow: var(--glow-gold); animation: pulse 4s infinite; }
.gate h1 { font-family: var(--display-2); font-weight: 700; color: var(--gold-bright); margin: .4rem 0; }
.gate-sub { color: var(--parch-dim); font-style: italic; margin-bottom: 1.6rem; }
.gate-error { color: #f0a5a5; }
.gate form { display: flex; flex-direction: column; gap: 1rem; margin: 1.4rem 0; }
.gate input { padding: .8rem 1rem; text-align: center; font-family: var(--serif); font-size: 1.1rem;
    color: var(--parchment); background: rgba(10,7,18,.7); border: 1px solid var(--line); border-radius: 10px; }

/* === Footer =========================================================== */
.footnote { text-align: center; padding: 2.4rem 1rem; color: var(--parch-dim);
    font-style: italic; border-top: 1px solid var(--line); font-size: .95rem; }

/* === Responsive ======================================================= */
@media (max-width: 760px) {
    .codex { grid-template-columns: 1fr; }
    .codex-cover { max-width: 280px; margin: 0 auto; }
    .grid2 { grid-template-columns: 1fr; }
    .grimoire-header { gap: 1rem; }
}
