/* =========================================================
   THEME TOKENS
   Light mode is the default; dark mode overrides via
   [data-theme="dark"] on <html>. Toggle logic in theme.js.
   ========================================================= */
:root {
    --parchment: #EFE6D6;
    --parchment-soft: #E4D9C4;
    --ink: #2B2621;
    --ink-soft: #59503f;
    --forest: #2F4538;
    --brass: #B08D57;
    --oxblood: #7B2D26;
    --card-shadow: 0 6px 24px rgba(43, 38, 33, 0.12);
    --border-hairline: rgba(43, 38, 33, 0.18);

    --bg: var(--parchment);
    --bg-soft: var(--parchment-soft);
    --text: var(--ink);
    --text-soft: var(--ink-soft);
    --accent: var(--forest);
    --accent-2: var(--brass);
    --link: var(--oxblood);
}

html[data-theme="dark"] {
    --bg: #1B1A17;
    --bg-soft: #242220;
    --text: #EFE6D6;
    --text-soft: #c9bfa9;
    --accent: #7fae94;
    --accent-2: #d8b787;
    --link: #d98b81;
    --border-hairline: rgba(239, 230, 214, 0.16);
    --card-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 1.05rem;
    line-height: 1.65;
    transition: background 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4 {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 600;
    line-height: 1.15;
    color: var(--text);
    margin: 0 0 0.5em;
}

h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); font-weight: 500; }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }

a { color: var(--link); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

.eyebrow {
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 600;
}

/* Visible keyboard focus everywhere */
a:focus-visible, button:focus-visible, input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* =========================================================
   SITE HEADER / NAV
   ========================================================= */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-hairline);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.site-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.site-title a { color: var(--text); }
.site-title a:hover { text-decoration: none; color: var(--accent); }

nav.main-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.6rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
}

nav.main-nav a {
    color: var(--text-soft);
}
nav.main-nav a:hover, nav.main-nav a.active {
    color: var(--accent);
}

/* --- Theme toggle: clear labeled button, matching the buy-link button style --- */
.ribbon-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    border: 1px solid var(--accent);
    border-radius: 20px;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}
.ribbon-toggle:hover {
    background: var(--accent);
    color: var(--bg);
}
.ribbon-toggle .ribbon-icon {
    font-size: 1.05rem;
    line-height: 1;
}
@media (max-width: 640px) {
    .ribbon-toggle .ribbon-label { display: none; }
    .ribbon-toggle { padding: 0.55rem 0.7rem; }
}

/* =========================================================
   HOME / HERO
   ========================================================= */
.hero {
    padding: 4rem 0 3rem;
}
.hero-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 3rem;
    align-items: center;
}
@media (max-width: 720px) {
    .hero-grid { grid-template-columns: 1fr; }
}

.hero .eyebrow { display: block; margin-bottom: 0.8rem; }

.hero-cover {
    display: flex;
    justify-content: center;
}
.hero-cover a { display: block; text-decoration: none; }
.hero-cover img {
    max-width: 100%;
    width: 320px;
    box-shadow: var(--card-shadow);
    border-radius: 2px;
}
.hero-cover .cover-placeholder {
    width: 260px;
    height: 380px;
    background: var(--bg-soft);
    border: 1px dashed var(--border-hairline);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    color: var(--text-soft);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    border-radius: 2px;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.6rem;
    margin: 1.8rem 0 2.5rem;
}
.book-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.book-card-link:hover .book-card {
    box-shadow: var(--card-shadow);
    border-color: var(--accent);
}
.book-card-link:hover h3 {
    color: var(--accent);
}
.book-card {
    background: var(--bg-soft);
    border: 1px solid var(--border-hairline);
    border-radius: 4px;
    padding: 1.4rem;
    position: relative;
    transition: border-color 0.15s ease;
}
.book-card img {
    width: 100%;
    max-width: 160px;
    display: block;
    margin: 0 auto 1rem;
    box-shadow: var(--card-shadow);
    border-radius: 2px;
}
.book-card h3 { font-size: 1.15rem; margin-bottom: 0.3rem; transition: color 0.15s ease; }
.book-card p { font-size: 0.92rem; }
.book-card p.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-soft);
    margin: 0;
}
.book-card .buy-links { margin-top: 1rem; }
.book-card .buy-links a { font-size: 0.75rem; padding: 0.45rem 0.8rem; }

.cover-placeholder.small {
    width: 100%;
    max-width: 160px;
    height: 220px;
    margin: 0 auto 1rem;
    font-size: 0.75rem;
}

.book-card.coming-soon {
    border-color: var(--accent-2);
}
.status-badge {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    background: var(--brass);
    color: var(--ink);
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.25rem 0.6rem;
    border-radius: 3px;
}
.release-date {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    color: var(--text-soft);
    font-style: italic;
}

.buy-links {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}
.buy-links a {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.6rem 1.1rem;
    border: 1px solid var(--accent);
    color: var(--accent);
    border-radius: 3px;
    letter-spacing: 0.02em;
}
.buy-links a:hover {
    background: var(--accent);
    color: var(--bg);
    text-decoration: none;
}

/* =========================================================
   SIGNUP - styled like a library card
   ========================================================= */
.library-card {
    background: var(--bg-soft);
    border: 1px solid var(--border-hairline);
    border-radius: 4px;
    padding: 2rem;
    margin: 3rem 0;
    position: relative;
}
.library-card::before {
    content: "";
    position: absolute;
    top: 0; left: 2rem;
    width: 40px; height: 10px;
    background: var(--brass);
    border-radius: 0 0 3px 3px;
}
.library-card h3 { margin-bottom: 0.3rem; }
.library-card p.card-note {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    color: var(--text-soft);
    margin-bottom: 1.2rem;
}
.magnet-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 1.5rem;
    align-items: start;
}
@media (max-width: 560px) {
    .magnet-grid { grid-template-columns: 1fr; }
    .magnet-cover { max-width: 160px; margin: 0 auto; }
}
.magnet-cover {
    min-width: 0;
    max-width: 140px;
}
.magnet-cover img {
    width: 100%;
    max-width: 100%;
    height: auto;
    box-shadow: var(--card-shadow);
    border-radius: 2px;
    display: block;
}
.signup-form {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
}
.signup-form input[type="email"] {
    flex: 1;
    min-width: 220px;
    padding: 0.75rem 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    border: 1px solid var(--border-hairline);
    border-radius: 3px;
    background: var(--bg);
    color: var(--text);
}
.signup-form button {
    padding: 0.75rem 1.4rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    background: var(--forest);
    color: var(--parchment);
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.2s ease;
}
.signup-form button:hover { background: var(--oxblood); }

.form-message {
    margin-top: 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
}
.form-message.success { color: var(--forest); }
.form-message.error { color: var(--oxblood); }

/* =========================================================
   GALLERY
   ========================================================= */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.2rem;
    margin: 2rem 0;
}
.gallery-grid figure {
    margin: 0;
    background: var(--bg-soft);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
}
.gallery-grid img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
}
.gallery-grid figcaption {
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    color: var(--text-soft);
    padding: 0.6rem 0.8rem;
}
.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--text-soft);
    font-family: 'Inter', sans-serif;
    border: 1px dashed var(--border-hairline);
    border-radius: 4px;
}

/* =========================================================
   ABOUT
   ========================================================= */
.about-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 2.5rem;
    align-items: start;
    margin: 2.5rem 0;
}
@media (max-width: 640px) {
    .about-grid { grid-template-columns: 1fr; }
}
.about-grid img {
    width: 100%;
    border-radius: 4px;
    box-shadow: var(--card-shadow);
}

/* =========================================================
   ADMIN
   ========================================================= */
.admin-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}
.admin-login {
    max-width: 380px;
    margin: 4rem auto;
    padding: 2.5rem;
    background: var(--bg-soft);
    border-radius: 6px;
    box-shadow: var(--card-shadow);
}
.admin-login input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-hairline);
    border-radius: 3px;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
}
.admin-login button, .btn {
    display: inline-block;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    padding: 0.7rem 1.2rem;
    background: var(--forest);
    color: var(--parchment);
    border: none;
    border-radius: 3px;
    cursor: pointer;
}
.btn.danger { background: var(--oxblood); }
.btn.secondary { background: transparent; border: 1px solid var(--accent); color: var(--accent); }

table.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    margin: 1.5rem 0;
}
table.admin-table th, table.admin-table td {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border-hairline);
}
table.admin-table th {
    font-weight: 600;
    color: var(--text-soft);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.admin-field { margin-bottom: 1.3rem; }
.admin-field label {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-soft);
    margin-bottom: 0.4rem;
}
.admin-field input[type=text], .admin-field textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border-hairline);
    border-radius: 3px;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
}
.admin-field textarea { min-height: 120px; resize: vertical; }

.generated-links {
    background: var(--bg-soft);
    border-radius: 4px;
    padding: 1rem 1.2rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
}
.generated-links code { word-break: break-all; }

.alert {
    padding: 0.8rem 1.1rem;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    margin-bottom: 1.2rem;
}
.alert.success { background: rgba(47, 69, 56, 0.15); color: var(--forest); }
.alert.error { background: rgba(123, 45, 38, 0.15); color: var(--oxblood); }

/* =========================================================
   FOOTER
   ========================================================= */
footer.site-footer {
    margin-top: 4rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border-hairline);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    color: var(--text-soft);
    text-align: center;
}

/* Skip-to-content link: off-screen until it receives keyboard focus, then
   it appears in the top-left. Deliberately not display:none — that would
   hide it from screen readers too, defeating the point. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    padding: 0.7rem 1.1rem;
    background: var(--accent);
    color: var(--bg);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}
.skip-link:focus {
    left: 0;
}
/* The skip target shouldn't draw a focus ring when jumped to — the heading
   below it is what the user is actually being sent to. */
main:focus {
    outline: none;
}

/* Book detail page layout.
   The shared .hero-grid centres its columns vertically, which reads fine on
   the home page where the intro text is short. A book blurb runs to several
   paragraphs, so centring left the cover stranded halfway down beside the
   middle of the text. Top-align it here only - the home page is unchanged. */
.hero-book .hero-grid {
    align-items: start;
}

/* On narrow screens the grid collapses to one column and, in DOM order, the
   cover would land below the entire blurb - you'd scroll past everything to
   see what the book looks like. Pull it above the text instead. */
@media (max-width: 720px) {
    .hero-book .hero-cover { order: -1; margin-bottom: 1.5rem; }
}

/* =========================================================
   FORMAT LABELS + REVIEW PAGE
   ========================================================= */

/* Small heading above a group of buy or review buttons. A real <h2> so
   screen readers get the structure, styled down so it doesn't shout. */
.format-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-soft);
    margin: 1.8rem 0 0;
}
.format-label + .buy-links { margin-top: 0.7rem; }

.review-page {
    max-width: 620px;
    padding-top: 3rem;
    padding-bottom: 3rem;
}

/* The review buttons are the one job of this page, so they're bigger than
   the standard buy links. Readers arrive from a QR code, which means they
   are almost certainly on a phone with the book still in their other hand. */
.review-buttons a {
    font-size: 0.95rem;
    padding: 0.85rem 1.4rem;
}
@media (max-width: 520px) {
    /* Full-width targets beat a cramped row of three on a small screen. */
    .review-buttons { flex-direction: column; }
    .review-buttons a { text-align: center; }
}

.review-note {
    font-family: 'Inter', sans-serif;
    font-size: 0.86rem;
    line-height: 1.6;
    color: var(--text-soft);
    margin-top: 1.6rem;
}

.review-divider {
    border: 0;
    border-top: 1px solid var(--border-hairline);
    margin: 2.8rem 0 1.6rem;
}

.review-footnote {
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-soft);
}

/* Book chooser on /review, shown once more than one book is released.
   Covers sized to match the Ebenezer Dawn cover on the home page. */
.review-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-top: 2.2rem;
}
.review-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    width: 140px;
    text-decoration: none;
    color: var(--text);
}
.review-choice img {
    width: 100%;
    box-shadow: var(--card-shadow);
    border-radius: 2px;
    /* A cover is the thing being clicked, so it should respond like a
       control rather than sitting there inertly. */
    transition: transform 0.15s ease;
}
.review-choice:hover img,
.review-choice:focus-visible img { transform: translateY(-3px); }
.review-choice-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.35;
}
.review-choice:hover .review-choice-title { text-decoration: underline; }

@media (max-width: 520px) {
    /* Two per row on a phone rather than one huge column. */
    .review-choices { gap: 1.4rem; justify-content: center; }
    .review-choice { width: calc(50% - 0.7rem); max-width: 160px; }
}

/* Secondary links under a book's buy buttons - for readers who aren't here
   to buy. Stacked rather than inline so "read reviews" and "leave a review"
   don't read as one confusing sentence. */
.book-extras {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
    margin-top: 1.6rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
}
