/* =============================================================================
   The Publishing Store — Dark Academia theme
   "ex libris · ex litteris"
   ============================================================================= */

/* --- @font-face ----------------------------------------------------------- */

@font-face {
    font-family: 'EB Garamond';
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url('/fonts/eb-garamond.woff2') format('woff2');
}
@font-face {
    font-family: 'EB Garamond';
    font-style: italic;
    font-weight: 400 600;
    font-display: swap;
    src: url('/fonts/eb-garamond-italic.woff2') format('woff2');
}
@font-face {
    font-family: 'IM Fell English';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/im-fell-english.woff2') format('woff2');
}
@font-face {
    font-family: 'IM Fell English';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/im-fell-english-italic.woff2') format('woff2');
}

/* --- Design tokens -------------------------------------------------------- */

:root {
    /* Color: candlelit library */
    --ink:          #1C1812;   /* deep night-time mahogany */
    --ink-lift:     #221C14;   /* very slight surface lift */
    --ink-card:     #271F16;   /* card/table background */
    --mahogany:     #5C4033;   /* primary — leather, wood paneling */
    --mahogany-dk:  #3D2A22;   /* darker mahogany for shadows */
    --gilt:         #8B7D6B;   /* secondary — faded gold leaf, dust */
    --gilt-lt:      #A89680;   /* lifted gilt for hover states */
    --parchment:    #E8DCC8;   /* primary text — candlelit page */
    --parchment-dim:#C9BCA3;   /* muted parchment */
    --wine:         #8B0000;   /* accent — library red, ink, wax seal */
    --wine-lt:      #A32020;   /* wine highlight */
    --wine-dk:      #5F0000;

    /* Typography */
    --font-display: 'IM Fell English', 'Palatino Linotype', Palatino, Georgia, serif;
    --font-body:    'EB Garamond', 'Palatino Linotype', Palatino, Georgia, serif;

    /* Scale — rooted in 19px body for scholarly comfort */
    --fs-micro:  0.68rem;
    --fs-small:  0.82rem;
    --fs-base:   1.12rem;
    --fs-lead:   1.28rem;
    --fs-h6:     1rem;
    --fs-h5:     1.35rem;
    --fs-h4:     1.75rem;
    --fs-h3:     2.5rem;
    --fs-h2:     3.5rem;
    --fs-h1:     5.5rem;

    /* Layout */
    --page-max:    76rem;
    --content-max: 64rem;
    --prose-max:   38rem;
    --radius:      3px;
    --border:      1px solid var(--mahogany);
    --border-fine: 1px solid rgba(139, 125, 107, 0.35);
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(139, 125, 107, 0.12);
    --shadow-book: 0 18px 40px rgba(0, 0, 0, 0.6), 0 2px 0 rgba(232, 220, 200, 0.05) inset;
    --letter-eyebrow: 0.32em;
    --letter-caps:    0.12em;
}

/* --- Reset / normalize ---------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4, h5, h6, p, ul, ol, figure { margin: 0; }
ul { list-style: none; padding: 0; }
input, button, select, textarea { color: inherit; font: inherit; }

/* --- Global atmosphere ---------------------------------------------------- */

html {
    background: var(--ink);
    color: var(--parchment);
    font-family: var(--font-body);
    font-size: 19px;
    line-height: 1.62;
    font-feature-settings: "liga", "kern", "onum", "hlig";
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100vh;
    /* Candlelit vignette — warmer light pulled toward upper-center, falling off into shadow */
    background:
        radial-gradient(ellipse 90% 70% at 50% -10%,
            rgba(139, 125, 107, 0.22),
            transparent 55%),
        radial-gradient(ellipse 80% 60% at 15% 35%,
            rgba(92, 64, 51, 0.18),
            transparent 65%),
        radial-gradient(ellipse 75% 60% at 85% 80%,
            rgba(92, 64, 51, 0.14),
            transparent 68%),
        radial-gradient(ellipse 130% 110% at 50% 50%,
            transparent 0%,
            rgba(0, 0, 0, 0.6) 90%),
        var(--ink);
    background-attachment: fixed;
    position: relative;
    overflow-x: hidden;
}

/* Grain overlay — subtle paper tooth so flat surfaces don't feel plastic */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.28;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.05' numOctaves='3' seed='11' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.58 0 0 0 0 0.48 0 0 0 0 0.36 0 0 0 0.95 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* Second texture layer — faint horizontal ruling like aged laid paper */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.1;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent 0,
            transparent 3px,
            rgba(139, 125, 107, 0.5) 3px,
            rgba(139, 125, 107, 0.5) 4px
        );
}

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

/* --- Typography primitives ----------------------------------------------- */

.display, h1, h2 {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.04;
    color: var(--parchment);
    letter-spacing: -0.005em;
}

h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.2;
    color: var(--parchment);
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }
h5 { font-size: var(--fs-h5); }
h6 { font-size: var(--fs-h6); }

p { font-size: var(--fs-base); }
p + p { margin-top: 0.9em; text-indent: 1.5em; }

.lead {
    font-size: var(--fs-lead);
    font-style: italic;
    color: var(--parchment-dim);
    line-height: 1.55;
}

.eyebrow,
.small-caps-label {
    display: inline-block;
    font-family: var(--font-body);
    font-size: var(--fs-micro);
    font-weight: 500;
    letter-spacing: var(--letter-eyebrow);
    text-transform: uppercase;
    color: var(--gilt);
}

.caps {
    font-variant: small-caps;
    letter-spacing: var(--letter-caps);
}

.italic { font-style: italic; }

.muted { color: var(--gilt); }
.wine  { color: var(--wine); }
.parchment { color: var(--parchment); }
.mono { font-family: 'IM Fell English', serif; font-feature-settings: "tnum"; }

/* Latin-style subtitle under brand headlines */
.latin {
    display: block;
    font-family: var(--font-body);
    font-style: italic;
    font-size: var(--fs-base);
    color: var(--gilt);
    letter-spacing: 0.02em;
    margin-top: 0.6em;
}

/* Drop cap — first letter enlarged, accent-colored, on body prose */
.drop-cap::first-letter,
.drop-cap > p:first-child::first-letter {
    font-family: var(--font-display);
    font-size: 4.4em;
    line-height: 0.85;
    float: left;
    padding: 0.12em 0.08em 0 0;
    margin-right: 0.06em;
    color: var(--wine);
    font-feature-settings: "smcp" 0;
}

/* --- Links ---------------------------------------------------------------- */

a {
    color: var(--parchment);
    text-decoration: none;
    background-image: linear-gradient(var(--gilt), var(--gilt));
    background-repeat: no-repeat;
    background-size: 100% 1px;
    background-position: 0 100%;
    transition: color 0.2s ease, background-size 0.2s ease;
}
a:hover {
    color: var(--wine-lt);
    background-image: linear-gradient(var(--wine-lt), var(--wine-lt));
    background-size: 100% 2px;
}
a.unlink {
    background-image: none;
    color: inherit;
}
a.unlink:hover { color: var(--parchment); background-image: none; }

/* --- Ornamental dividers -------------------------------------------------- */

.rule {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(139, 125, 107, 0.4) 20%,
        rgba(139, 125, 107, 0.65) 50%,
        rgba(139, 125, 107, 0.4) 80%,
        transparent 100%);
    margin: 2.5rem 0;
}

/* Ornamental chapter divider — pair of hairlines with a glyph between */
.ornament-rule {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin: 3rem 0;
    color: var(--gilt);
}
.ornament-rule::before,
.ornament-rule::after {
    content: "";
    flex: 1;
    height: 0;
    border-top: 1px solid rgba(139, 125, 107, 0.45);
    box-shadow: 0 3px 0 -2px rgba(139, 125, 107, 0.25);
}
.ornament-rule > span {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.4rem;
    letter-spacing: 0.15em;
    white-space: nowrap;
}

/* Section marker — e.g., "§ I — The Catalogue" */
.section-mark {
    display: flex;
    align-items: baseline;
    gap: 0.8rem;
    margin-bottom: 2rem;
}
.section-mark .mark {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--wine);
    letter-spacing: 0.25em;
    text-transform: uppercase;
}
.section-mark h2,
.section-mark h3 {
    font-style: italic;
}

/* --- Layout: the page frame ---------------------------------------------- */

.container {
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 2.5rem;
}
.container--narrow {
    max-width: var(--content-max);
}
.container--prose {
    max-width: var(--prose-max);
}

main {
    padding: 3rem 0 5rem;
}

/* --- Navigation header --------------------------------------------------- */

.site-header {
    padding: 3rem 0 2rem;
    border-bottom: 1px solid rgba(92, 64, 51, 0.55);
    background:
        linear-gradient(180deg, rgba(0,0,0,0.55), transparent 90%);
    position: relative;
}
.site-header::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -3px;
    height: 1px;
    background: linear-gradient(90deg,
        transparent, rgba(139, 125, 107, 0.4) 20%,
        rgba(139, 125, 107, 0.6) 50%,
        rgba(139, 125, 107, 0.4) 80%, transparent);
}

.site-header__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 2.5rem;
}

.brand {
    justify-self: start;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    line-height: 1;
    position: relative;
    padding-bottom: 0.8rem;
    background-image: none;
}
.brand::after {
    content: "";
    position: absolute;
    left: 0;
    right: 40%;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg,
        rgba(139, 125, 107, 0.6) 0%,
        rgba(139, 125, 107, 0.15) 100%);
}
.brand__name {
    font-family: var(--font-display);
    font-size: 2.35rem;
    font-style: italic;
    color: var(--parchment);
    letter-spacing: 0.008em;
    line-height: 1;
}
.brand__sub {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-style: italic;
    color: var(--gilt);
    letter-spacing: 0.32em;
    text-transform: lowercase;
}

.site-header__mark {
    justify-self: center;
    color: var(--gilt);
    font-size: 1.9rem;
    letter-spacing: 0.45em;
    line-height: 1;
    opacity: 0.85;
}

.nav-primary {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 1.8rem;
}
.nav-primary a,
.nav-primary form button.link {
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-variant: small-caps;
    letter-spacing: var(--letter-caps);
    color: var(--parchment-dim);
    background: none;
    border: none;
    padding: 0;
    background-image: none;
    transition: color 0.2s ease;
}
.nav-primary a:hover,
.nav-primary form button.link:hover {
    color: var(--wine-lt);
    background-image: none;
}
.nav-primary .sep {
    font-family: var(--font-display);
    color: var(--mahogany);
    font-size: 0.9rem;
}

/* --- Footer --------------------------------------------------------------- */

.site-footer {
    margin-top: 6rem;
    padding: 3.5rem 0 2.5rem;
    border-top: 1px solid rgba(92, 64, 51, 0.55);
    text-align: center;
    font-size: var(--fs-small);
    color: var(--gilt);
    font-style: italic;
    position: relative;
}
.site-footer::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: linear-gradient(90deg,
        transparent,
        rgba(139, 125, 107, 0.5) 20%,
        rgba(139, 125, 107, 0.75) 50%,
        rgba(139, 125, 107, 0.5) 80%,
        transparent);
}
.site-footer .ornament {
    font-family: var(--font-display);
    font-size: 2.2rem;
    letter-spacing: 0.5em;
    margin-bottom: 1.2rem;
    color: var(--gilt);
    font-style: normal;
    opacity: 0.85;
}
.site-footer p { font-size: inherit; }
.site-footer p + p { text-indent: 0; margin-top: 0.4em; }

/* --- Hero / page-opening -------------------------------------------------- */

.page-hero {
    text-align: center;
    padding: 4.5rem 0 2rem;
    position: relative;
}
.page-hero .eyebrow { margin-bottom: 1.4rem; }

/* Oversized gilt ornament above the eyebrow — establishes the chapter opening */
.page-hero__crest {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 4rem;
    color: var(--gilt);
    line-height: 1;
    margin-bottom: 1.2rem;
    letter-spacing: 0.3em;
    display: block;
    opacity: 0.88;
    text-shadow: 0 2px 18px rgba(139, 125, 107, 0.25);
}
.page-hero__crest--small {
    font-size: 2.4rem;
    margin-bottom: 0.8rem;
}

.page-hero h1 {
    font-style: italic;
    font-size: var(--fs-h1);
    line-height: 0.98;
    text-shadow: 0 2px 30px rgba(0, 0, 0, 0.5);
}
.page-hero h1 .serif-roman {
    font-style: normal;
    font-variant: small-caps;
    letter-spacing: 0.04em;
    color: var(--wine);
    display: block;
    text-shadow: 0 2px 24px rgba(139, 0, 0, 0.4);
}
.page-hero .latin {
    margin-top: 1.6rem;
    font-size: 1.05rem;
    letter-spacing: 0.18em;
}

.page-hero__frame {
    display: inline-block;
    border-top: 1px solid rgba(139, 125, 107, 0.5);
    border-bottom: 1px solid rgba(139, 125, 107, 0.5);
    padding: 0.6rem 2.4rem;
    margin: 1.8rem 0 0.4rem;
    position: relative;
}
.page-hero__frame::before,
.page-hero__frame::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 6px;
    height: 6px;
    background: var(--gilt);
    border-radius: 50%;
    transform: translateY(-50%);
}
.page-hero__frame::before { left: -3px; }
.page-hero__frame::after  { right: -3px; }
.page-hero__frame .eyebrow { color: var(--gilt); letter-spacing: 0.35em; }

/* --- The tome: card that frames a book or entry -------------------------- */

.tome {
    background:
        linear-gradient(180deg, rgba(92, 64, 51, 0.22), rgba(92, 64, 51, 0.08)),
        var(--ink-card);
    border: 1px solid rgba(139, 125, 107, 0.38);
    border-radius: var(--radius);
    padding: 1.9rem 2rem;
    position: relative;
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(139, 125, 107, 0.1);
}
.tome::before {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(139, 125, 107, 0.15);
    border-radius: 2px;
    pointer-events: none;
}
.tome__body { display: flex; flex-direction: column; gap: 0.5rem; }

/* An "index card" layout for listings */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
    gap: 2.5rem 3rem;
    margin-top: 3rem;
    max-width: 70rem;
    margin-left: auto;
    margin-right: auto;
}

.book-card {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 1.1rem;
    padding: 2rem 2rem 1.7rem;
    border: 1px solid rgba(139, 125, 107, 0.38);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(92, 64, 51, 0.25) 0%, rgba(92, 64, 51, 0.08) 100%),
        var(--ink-card);
    position: relative;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    box-shadow:
        0 2px 0 rgba(0, 0, 0, 0.4),
        0 14px 32px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(232, 220, 200, 0.04);
}
.book-card::before {
    /* inner gilt hairline — the classic fine-binding detail */
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(139, 125, 107, 0.2);
    border-radius: 2px;
    pointer-events: none;
}
.book-card:hover {
    transform: translateY(-3px);
    border-color: rgba(139, 125, 107, 0.7);
    box-shadow: var(--shadow-book);
}
.book-card__catalog {
    font-family: var(--font-body);
    font-size: var(--fs-micro);
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--gilt);
    display: flex;
    justify-content: space-between;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid rgba(139, 125, 107, 0.22);
}
.book-card__title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.7rem;
    line-height: 1.1;
    color: var(--parchment);
    background-image: none;
    display: block;
}
.book-card__title:hover { color: var(--wine-lt); background-image: none; }
.book-card__author {
    font-size: 0.95rem;
    font-style: italic;
    color: var(--gilt);
    margin-top: 0.3rem;
}
.book-card__blurb {
    font-size: 0.93rem;
    color: var(--parchment-dim);
    font-style: italic;
    line-height: 1.55;
    margin-top: 0.6rem;
}
.book-card__foot {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid rgba(139, 125, 107, 0.22);
}
.book-card__price {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.8rem;
    color: var(--wine);
    line-height: 1;
}

/* --- Book detail page ----------------------------------------------------- */

.book-detail {
    display: grid;
    grid-template-columns: 1fr 1.8fr;
    gap: 3.5rem;
    margin-top: 2rem;
}
@media (max-width: 780px) {
    .book-detail { grid-template-columns: 1fr; }
}

.book-detail__cover-frame {
    aspect-ratio: 2 / 3;
    border: 1px solid rgba(139, 125, 107, 0.7);
    background:
        radial-gradient(ellipse at 30% 20%, rgba(139, 125, 107, 0.18), transparent 70%),
        linear-gradient(135deg, var(--mahogany-dk), var(--mahogany) 55%, var(--mahogany-dk)),
        var(--mahogany);
    box-shadow:
        0 40px 60px rgba(0, 0, 0, 0.8),
        0 0 80px rgba(139, 0, 0, 0.08),
        inset 0 0 0 1px rgba(139, 125, 107, 0.55),
        inset 0 0 0 7px var(--mahogany-dk),
        inset 0 0 0 8px rgba(139, 125, 107, 0.55),
        inset 0 0 0 9px rgba(139, 125, 107, 0.15);
    position: relative;
    overflow: hidden;
}
.book-detail__cover-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.book-detail__cover-frame .spine {
    position: absolute;
    inset: 8% 12% 8% 12%;
    border: 1px solid rgba(139, 125, 107, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    text-align: center;
    color: var(--parchment);
    padding: 1.5rem;
}
.spine__glyph {
    font-family: var(--font-display);
    font-size: 2.8rem;
    color: var(--gilt);
}
.spine__title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.3rem;
    color: var(--parchment);
    line-height: 1.2;
}
.spine__rule {
    width: 40%;
    border-top: 1px solid rgba(139, 125, 107, 0.5);
}
.spine__author {
    font-size: 0.78rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--gilt);
}

.book-detail__info .eyebrow { display: block; margin-bottom: 0.6rem; }
.book-detail__info h1 {
    font-style: italic;
    font-size: var(--fs-h2);
    line-height: 1.02;
    letter-spacing: -0.01em;
}
.book-detail__info .by {
    font-style: italic;
    font-size: 1.2rem;
    color: var(--gilt);
    margin: 0.4rem 0 1.6rem;
}
.book-detail__price-row {
    display: flex;
    align-items: baseline;
    gap: 2rem;
    margin: 1.8rem 0 2rem;
    padding: 1.2rem 0;
    border-top: 1px solid rgba(139, 125, 107, 0.35);
    border-bottom: 1px solid rgba(139, 125, 107, 0.35);
}
.book-detail__price {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--wine);
    font-size: 3.2rem;
    line-height: 1;
}
.book-detail__price-sub {
    font-size: var(--fs-micro);
    letter-spacing: var(--letter-eyebrow);
    color: var(--gilt);
    text-transform: uppercase;
}
.book-detail .book-description {
    margin-top: 2rem;
    max-width: 36rem;
}
.book-detail .book-description p { font-size: 1.02rem; line-height: 1.7; }

/* --- Format badges -------------------------------------------------------- */

.formats {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin: 1.2rem 0 0;
}
.format-badge {
    font-family: var(--font-body);
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--gilt);
    padding: 0.35rem 0.85rem;
    border: 1px solid rgba(139, 125, 107, 0.5);
    border-radius: 2px;
    background: rgba(92, 64, 51, 0.15);
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    font-variant: small-caps;
    letter-spacing: 0.18em;
    padding: 0.85rem 1.6rem;
    border-radius: var(--radius);
    border: 1px solid var(--mahogany);
    background: var(--mahogany);
    color: var(--parchment);
    text-decoration: none;
    background-image: none;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.12s ease;
    text-transform: none;
    box-shadow: inset 0 0 0 1px rgba(232, 220, 200, 0.08);
}
.btn:hover {
    background: var(--wine);
    border-color: var(--wine);
    color: var(--parchment);
    background-image: none;
}
.btn:active { transform: translateY(1px); }

.btn--ghost {
    background: transparent;
    color: var(--gilt);
    border-color: rgba(139, 125, 107, 0.5);
    box-shadow: none;
}
.btn--ghost:hover {
    background: rgba(139, 125, 107, 0.08);
    border-color: var(--gilt);
    color: var(--parchment);
}

.btn--wine {
    background: var(--wine);
    border-color: var(--wine);
}
.btn--wine:hover {
    background: var(--wine-dk);
    border-color: var(--wine-dk);
}

.btn--block { width: 100%; }

.btn--large {
    padding: 1.1rem 2rem;
    font-size: 0.9rem;
    letter-spacing: 0.2em;
}

.btn--icon {
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
}

/* Ornamental "quill" CTA */
.btn .quill-glyph {
    font-family: var(--font-display);
    font-style: italic;
    letter-spacing: 0;
}

/* --- Forms --------------------------------------------------------------- */

.form-field { display: block; margin-bottom: 1.8rem; }
.form-field label {
    display: block;
    font-family: var(--font-body);
    font-size: var(--fs-micro);
    letter-spacing: var(--letter-eyebrow);
    text-transform: uppercase;
    color: var(--gilt);
    margin-bottom: 0.55rem;
}
.form-control {
    width: 100%;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.2rem;
    background: transparent;
    color: var(--parchment);
    padding: 0.5rem 0 0.65rem;
    border: 0;
    border-bottom: 1px solid rgba(139, 125, 107, 0.45);
    transition: border-color 0.2s ease;
}
.form-control:focus {
    outline: none;
    border-bottom-color: var(--wine);
}
.form-control::placeholder {
    color: rgba(139, 125, 107, 0.6);
    font-style: italic;
}
.form-text {
    display: block;
    margin-top: 0.5rem;
    font-size: var(--fs-small);
    color: var(--gilt);
    font-style: italic;
}

/* --- Alerts (used by login errors, cart discount messages) --------------- */

.alert {
    padding: 0.9rem 1.2rem;
    border: 1px solid rgba(139, 125, 107, 0.4);
    border-left-width: 3px;
    border-radius: var(--radius);
    background: rgba(92, 64, 51, 0.15);
    font-size: var(--fs-small);
    font-style: italic;
    margin-bottom: 1.4rem;
}
.alert--danger  { border-left-color: var(--wine);  color: var(--parchment); }
.alert--success { border-left-color: #6b8e23;       color: var(--parchment); }
.alert--warning { border-left-color: #b8860b;       color: var(--parchment); }
.alert--info    { border-left-color: var(--gilt);   color: var(--parchment); }

/* --- Ledger: table used for cart, orders -------------------------------- */

.ledger {
    width: 100%;
    border: 1px solid rgba(139, 125, 107, 0.38);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(92, 64, 51, 0.22), rgba(92, 64, 51, 0.08)),
        var(--ink-card);
    overflow: hidden;
    box-shadow:
        0 12px 28px rgba(0, 0, 0, 0.45),
        inset 0 0 0 1px rgba(139, 125, 107, 0.08);
}
.ledger th,
.ledger td {
    padding: 1.1rem 1.4rem;
    text-align: left;
    border-bottom: 1px solid rgba(139, 125, 107, 0.18);
    vertical-align: middle;
}
.ledger tr:last-child td { border-bottom: 0; }
.ledger thead th {
    font-family: var(--font-body);
    font-size: var(--fs-micro);
    text-transform: uppercase;
    letter-spacing: var(--letter-eyebrow);
    color: var(--gilt);
    font-weight: 500;
    background: rgba(92, 64, 51, 0.18);
    border-bottom: 1px solid rgba(139, 125, 107, 0.3);
}
.ledger .text-end   { text-align: right; }
.ledger .text-center{ text-align: center; }
.ledger .book-title {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.2rem;
    color: var(--parchment);
    line-height: 1.2;
}
.ledger .book-author {
    font-size: 0.88rem;
    color: var(--gilt);
    font-style: italic;
    margin-top: 0.2rem;
}
.ledger .price {
    font-family: var(--font-display);
    font-style: italic;
    color: var(--wine);
    font-size: 1.25rem;
}

/* --- Tally / summary card ------------------------------------------------ */

.tally {
    background:
        linear-gradient(180deg, rgba(92, 64, 51, 0.25), rgba(92, 64, 51, 0.1)),
        var(--ink-card);
    border: 1px solid rgba(139, 125, 107, 0.42);
    border-radius: var(--radius);
    padding: 2rem 2.2rem;
    position: relative;
    box-shadow:
        0 14px 32px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(139, 125, 107, 0.1),
        inset 0 1px 0 rgba(232, 220, 200, 0.05);
}
.tally::before {
    content: "";
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(139, 125, 107, 0.22);
    border-radius: 2px;
    pointer-events: none;
}
.tally__head {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.55rem;
    color: var(--parchment);
    text-align: center;
    margin-bottom: 0.6rem;
}
.tally__sub {
    text-align: center;
    font-size: var(--fs-micro);
    letter-spacing: var(--letter-eyebrow);
    text-transform: uppercase;
    color: var(--gilt);
    margin-bottom: 1.6rem;
}
.tally__row {
    display: flex;
    justify-content: space-between;
    padding: 0.55rem 0;
    font-size: 1rem;
}
.tally__row--muted { color: var(--gilt); font-style: italic; }
.tally__row + .tally__divider {
    border-top: 1px solid rgba(139, 125, 107, 0.3);
    margin: 0.8rem 0 0.6rem;
}
.tally__row--total {
    padding-top: 0.8rem;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.6rem;
    color: var(--wine);
    border-top: 1px solid rgba(139, 125, 107, 0.45);
    margin-top: 0.5rem;
}
.tally__actions {
    margin-top: 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

/* --- Requisition (cart) & reading room (auth) layouts ------------------- */

.requisition {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 2.5rem;
    margin-top: 2rem;
}
@media (max-width: 900px) { .requisition { grid-template-columns: 1fr; } }

.reading-room {
    max-width: 26rem;
    margin: 3.5rem auto 2rem;
}
.reading-room h1 {
    text-align: center;
    font-style: italic;
    font-size: var(--fs-h3);
    margin-bottom: 0.3rem;
}
.reading-room .latin {
    text-align: center;
    margin-bottom: 2.4rem;
}

/* --- Empty state --------------------------------------------------------- */

.empty-state {
    text-align: center;
    padding: 5rem 1rem 3rem;
}
.empty-state .glyph {
    font-family: var(--font-display);
    font-size: 4rem;
    color: var(--mahogany);
    margin-bottom: 1rem;
    display: block;
    font-style: italic;
}
.empty-state p {
    font-size: 1.15rem;
    font-style: italic;
    color: var(--gilt);
    margin-bottom: 2rem;
}

/* --- Library page (owned books) ----------------------------------------- */

.ex-libris {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    margin-top: 2rem;
}
.ex-libris__entry {
    display: grid;
    grid-template-columns: 6rem 1fr auto;
    gap: 1.8rem;
    align-items: center;
    padding: 1.5rem 1.8rem;
    border: 1px solid rgba(139, 125, 107, 0.38);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, rgba(92, 64, 51, 0.22), rgba(92, 64, 51, 0.08)),
        var(--ink-card);
    box-shadow:
        0 10px 24px rgba(0, 0, 0, 0.45),
        inset 0 0 0 1px rgba(139, 125, 107, 0.1);
    position: relative;
}
.ex-libris__entry::before {
    content: "";
    position: absolute;
    inset: 5px;
    border: 1px solid rgba(139, 125, 107, 0.12);
    border-radius: 2px;
    pointer-events: none;
}
.ex-libris__plate {
    aspect-ratio: 2 / 3;
    background:
        linear-gradient(135deg, var(--mahogany-dk), var(--mahogany) 60%, var(--mahogany-dk));
    border: 1px solid rgba(139, 125, 107, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gilt);
    font-family: var(--font-display);
    font-size: 2rem;
    font-style: italic;
}
.ex-libris__plate img { width: 100%; height: 100%; object-fit: cover; }
.ex-libris__meta h4 {
    font-style: italic;
    font-size: 1.4rem;
    line-height: 1.15;
}
.ex-libris__meta .by {
    font-style: italic;
    color: var(--gilt);
    font-size: 0.95rem;
    margin-top: 0.3rem;
}
.ex-libris__actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

/* --- Checkout specifics (Stripe card element) --------------------------- */

.checkout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 3rem;
    margin-top: 2rem;
}
@media (max-width: 900px) { .checkout { grid-template-columns: 1fr; } }

#card-element {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(139, 125, 107, 0.45);
    border-radius: var(--radius);
    min-height: 52px;
}
#card-errors {
    color: var(--wine-lt);
    font-style: italic;
    font-size: 0.92rem;
    margin-top: 0.6rem;
}

/* --- Confirmation page --------------------------------------------------- */

.receipt {
    max-width: 40rem;
    margin: 2rem auto;
    text-align: center;
}
.receipt__seal {
    width: 6.5rem;
    height: 6.5rem;
    margin: 0 auto 1.6rem;
    border-radius: 50%;
    border: 1px solid var(--wine);
    background:
        radial-gradient(circle at 35% 30%, var(--wine-lt), var(--wine-dk) 80%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 2.6rem;
    color: var(--parchment);
    box-shadow:
        0 8px 24px rgba(139, 0, 0, 0.35),
        inset 0 0 0 2px var(--wine-dk),
        inset 0 0 0 3px rgba(232, 220, 200, 0.25);
    letter-spacing: -0.02em;
}
.receipt h1 {
    font-style: italic;
    font-size: var(--fs-h3);
    margin-bottom: 0.6rem;
}
.receipt .ref {
    font-family: var(--font-body);
    font-size: var(--fs-micro);
    letter-spacing: var(--letter-eyebrow);
    text-transform: uppercase;
    color: var(--gilt);
    margin-bottom: 2rem;
}
.receipt .ref strong { color: var(--parchment); letter-spacing: 0.08em; }

.receipt__meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid rgba(139, 125, 107, 0.35);
    border-bottom: 1px solid rgba(139, 125, 107, 0.35);
    margin-bottom: 2rem;
}
.receipt__meta > div { text-align: center; }
.receipt__meta .label {
    font-size: var(--fs-micro);
    letter-spacing: var(--letter-eyebrow);
    text-transform: uppercase;
    color: var(--gilt);
    margin-bottom: 0.3rem;
}
.receipt__meta .val {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.2rem;
    color: var(--parchment);
}

/* --- Pagination ---------------------------------------------------------- */

.pager {
    margin-top: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}
.pager a,
.pager span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.4rem;
    height: 2.4rem;
    padding: 0 0.7rem;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--gilt);
    border: 1px solid transparent;
    background-image: none;
    border-radius: 2px;
    transition: all 0.2s ease;
}
.pager a:hover {
    color: var(--parchment);
    border-color: rgba(139, 125, 107, 0.4);
    background: rgba(92, 64, 51, 0.15);
    background-image: none;
}
.pager .current {
    color: var(--wine);
    border-color: var(--wine);
    background: rgba(139, 0, 0, 0.1);
}
.pager .disabled { opacity: 0.3; pointer-events: none; }

/* --- Utility layout helpers ---------------------------------------------- */

.stack > * + * { margin-top: 1.2rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.mt-0  { margin-top: 0; }
.mt-1  { margin-top: 0.8rem; }
.mt-2  { margin-top: 1.6rem; }
.mt-3  { margin-top: 2.4rem; }
.mt-4  { margin-top: 3rem; }
.mb-1  { margin-bottom: 0.8rem; }
.mb-2  { margin-bottom: 1.6rem; }
.mb-3  { margin-bottom: 2.4rem; }
.mb-4  { margin-bottom: 3rem; }

.hidden { display: none !important; }

/* --- Back link ----------------------------------------------------------- */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--fs-micro);
    letter-spacing: var(--letter-eyebrow);
    text-transform: uppercase;
    color: var(--gilt);
    background-image: none;
    margin-bottom: 2.4rem;
}
.back-link:hover {
    color: var(--wine-lt);
    background-image: none;
}
.back-link::before { content: "←"; font-size: 1rem; }

/* =============================================================================
   Mobile (≤780px) — stack the header, shrink hero scale, tighten padding
   ============================================================================= */
@media (max-width: 780px) {
    :root {
        --fs-h1: 3.4rem;
        --fs-h2: 2.6rem;
        --fs-h3: 2rem;
    }
    html { font-size: 17px; }
    .container { padding: 0 1.4rem; }
    main { padding: 2rem 0 3rem; }

    .site-header {
        padding: 1.6rem 0 1.3rem;
    }
    .site-header__inner {
        grid-template-columns: 1fr;
        gap: 1.2rem;
        justify-items: center;
        text-align: center;
    }
    .brand {
        justify-self: center;
        align-items: center;
        padding-bottom: 0.7rem;
    }
    .brand::after {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: 68%;
    }
    .brand__name {
        font-size: 1.85rem;
        text-align: center;
    }
    .brand__sub {
        letter-spacing: 0.3em;
        text-align: center;
    }
    .site-header__mark { display: none; }
    .nav-primary {
        justify-self: center;
        gap: 0.85rem 1.1rem;
        flex-wrap: wrap;
        justify-content: center;
    }
    .nav-primary .sep { font-size: 0.75rem; }
    .nav-primary a,
    .nav-primary form button.link { font-size: 0.7rem; }

    .page-hero { padding: 2.5rem 0 1rem; }
    .page-hero__crest { font-size: 2.8rem; margin-bottom: 0.9rem; }
    .page-hero h1 { line-height: 0.95; }
    .page-hero .latin { font-size: 0.92rem; }
    .page-hero__frame { padding: 0.5rem 1.5rem; }

    .book-grid { gap: 1.6rem; margin-top: 2rem; }
    .book-card { padding: 1.5rem 1.5rem 1.3rem; }
    .book-card__title { font-size: 1.5rem; }
    .book-card__price { font-size: 1.55rem; }

    .book-detail__info h1 { font-size: 2.6rem; }
    .book-detail__price { font-size: 2.4rem; }
    .book-detail__price-row { flex-wrap: wrap; gap: 1.2rem; }

    .ledger th, .ledger td { padding: 0.85rem 0.9rem; }
    .ledger .book-title { font-size: 1.05rem; }
    .ledger .price { font-size: 1.1rem; }

    .tally { padding: 1.6rem 1.5rem; }
    .tally__head { font-size: 1.35rem; }

    .receipt__meta {
        grid-template-columns: 1fr;
        gap: 1.1rem;
        padding: 1.3rem 1rem;
    }

    .reading-room { margin-top: 1.5rem; padding: 0 0.4rem; }

    .site-footer { margin-top: 3rem; padding: 2.4rem 0 1.8rem; }
    .site-footer .ornament { font-size: 1.6rem; }
}
