/* ============================================================
   Self-Study Press — design system
   Academic-professional, premium but restrained. CSS variables
   are the single source of truth (shared later by Products B/C).
   ============================================================ */

:root {
    --ink: #1a2333;          /* deep navy — headings, body */
    --ink-soft: #4a5568;     /* secondary text */
    --ink-faint: #8b95a5;
    --paper: #ffffff;
    --paper-warm: #f7f8fa;   /* alt sections */
    --line: #e4e8ee;
    --brand: #1f4e8c;        /* academic blue */
    --brand-dark: #163a6b;
    --accent: #d97b29;       /* warm amber accent */
    --success: #1f7a4d;
    --success-bg: #e8f5ee;
    --error: #b3352b;
    --error-bg: #fbebe9;
    --info: #1f4e8c;
    --info-bg: #e9f0f9;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(26, 35, 51, .07), 0 4px 14px rgba(26, 35, 51, .06);
    --shadow-lg: 0 4px 10px rgba(26, 35, 51, .08), 0 12px 32px rgba(26, 35, 51, .10);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --transition: 160ms ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.65;
    font-size: 16.5px;
}

img { max-width: 100%; }

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); margin-bottom: .75rem; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: .6rem; }
h3 { font-size: 1.18rem; margin-bottom: .5rem; }

p { margin-bottom: .9rem; }
a { color: var(--brand); }

.muted { color: var(--ink-soft); }
.small { font-size: .88rem; }
.center { text-align: center; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
.narrow { max-width: 780px; margin-left: auto; margin-right: auto; }
.narrow-form { max-width: 440px; margin-left: auto; margin-right: auto; }

.section { padding: 4rem 0; }
.section.alt { background: var(--paper-warm); }

/* ---------- Header / nav ---------- */

.site-header {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .95);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.admin-header { background: var(--ink); border-color: var(--ink); }
.admin-header .site-nav a, .admin-header .brand { color: #fff; }
.admin-header .brand span { color: var(--accent); }

.nav-row { display: flex; align-items: center; justify-content: space-between; min-height: 64px; gap: 1rem; }

.brand {
    font-weight: 800;
    font-size: 1.15rem;
    text-decoration: none;
    color: var(--ink);
    letter-spacing: -.02em;
}
.brand span { color: var(--brand); }

.site-nav { display: flex; align-items: center; gap: 1.4rem; }
.site-nav a { text-decoration: none; color: var(--ink-soft); font-weight: 500; font-size: .95rem; }
.site-nav a:hover { color: var(--ink); }

.nav-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--ink); }

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

.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: .6rem 1.25rem;
    font-size: .95rem;
    font-weight: 600;
    font-family: var(--font);
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff !important; }
.btn-primary:hover { background: var(--brand-dark); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brand); }
.btn-danger { background: var(--error); color: #fff !important; }
.btn-sm { padding: .35rem .8rem; font-size: .85rem; }
.btn-lg { padding: .8rem 1.7rem; font-size: 1.05rem; }
.btn-block { display: block; width: 100%; text-align: center; }

.inline-form { display: inline; }

/* ---------- Hero ---------- */

.hero { padding: 4.5rem 0 4rem; background: linear-gradient(180deg, #f2f6fb 0%, #ffffff 100%); }
.hero-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 3rem; align-items: center; }
.eyebrow {
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: .78rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: .8rem;
}
.hero h1 em { font-style: normal; color: var(--brand); }
.lead { font-size: 1.15rem; color: var(--ink-soft); }
.hero-cta { display: flex; gap: .8rem; flex-wrap: wrap; margin: 1.4rem 0 .8rem; }

.hero-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.8rem;
}

.hero-book { display: flex; justify-content: center; }
.hero-book img {
    display: block;
    width: 100%;
    max-width: 330px;
    height: auto;
    border-radius: 6px;
    transform: rotate(2deg);
    box-shadow: 0 10px 22px rgba(26, 35, 51, .16), 0 26px 60px rgba(26, 35, 51, .22);
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.stat { text-align: center; padding: .8rem .4rem; border-radius: var(--radius); background: var(--paper-warm); }
.stat strong { display: block; font-size: 1.9rem; color: var(--brand); letter-spacing: -.02em; }
.stat span { font-size: .82rem; color: var(--ink-soft); line-height: 1.3; display: block; }
.admin-stats { grid-template-columns: repeat(4, 1fr); }

/* ---------- Cards ---------- */

.card-grid { display: grid; gap: 1.4rem; margin-top: 2rem; }
.card-grid.three { grid-template-columns: repeat(3, 1fr); }
.card-grid.two { grid-template-columns: repeat(2, 1fr); }

.card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.6rem;
    box-shadow: var(--shadow);
}
.card-icon { font-size: 1.8rem; margin-bottom: .6rem; }

.badge {
    display: inline-block;
    background: var(--info-bg);
    color: var(--info);
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    padding: .25rem .75rem;
}
.badge-green { background: var(--success-bg); color: var(--success); }

/* ---------- TOC preview ---------- */

.toc-preview { display: grid; gap: .8rem; margin-top: 1.6rem; }
.toc-part {
    display: grid;
    gap: .15rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    background: #fff;
}
.toc-part span { color: var(--ink-soft); font-size: .92rem; }

/* ---------- Pricing ---------- */

.price-card {
    margin: 2.5rem auto 0;
    max-width: 520px;
    background: #fff;
    border: 1px solid var(--line);
    border-top: 5px solid var(--brand);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.2rem;
}
/* ---------- Book catalog & shelf ---------- */

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1.6rem;
    margin-top: 2rem;
}
.book-card {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    text-decoration: none;
    color: var(--ink);
}
.book-card .book-cover {
    width: 100%;
    aspect-ratio: 5 / 8;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    margin-bottom: .6rem;
    transition: transform var(--transition), box-shadow var(--transition);
}
.book-card:hover .book-cover { transform: translateY(-4px); box-shadow: 0 8px 16px rgba(26, 35, 51, .14), 0 20px 44px rgba(26, 35, 51, .18); }
.book-cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    box-sizing: border-box;
    background: linear-gradient(168deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff;
    font-weight: 700;
}
.book-card-title { font-weight: 700; line-height: 1.3; }
.book-card-sub { font-size: .85rem; }
.book-card-price { font-weight: 700; color: var(--brand); }

.shelf-title { margin: 1.4rem 0 0; }
.shelf { display: grid; gap: 1.2rem; margin-top: 1rem; }
.shelf-item { display: flex; gap: 1.4rem; align-items: center; }
.shelf-cover { width: 96px; height: auto; border-radius: 4px; box-shadow: var(--shadow); flex-shrink: 0; }
.shelf-body { flex: 1; min-width: 0; }
.shelf-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .7rem; }
.shelf-bar { display: block; max-width: 320px; margin-top: .3rem; }

/* ---------- Book sales page ---------- */

.bd-grid { display: grid; grid-template-columns: 320px 1fr; gap: 3rem; margin-top: 1rem; align-items: start; }
.bd-cover { width: 100%; height: auto; border-radius: 6px; box-shadow: var(--shadow-lg); }
.bd-cover-placeholder {
    aspect-ratio: 5 / 8;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.4rem;
    box-sizing: border-box;
    background: linear-gradient(168deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff;
    font-weight: 700;
    font-size: 1.3rem;
}
.bd-buy { margin-top: 1.6rem; border-top: 5px solid var(--brand); }

/* ---------- Admin product form ---------- */

.admin-form { display: grid; gap: 1rem; max-width: 680px; }
.admin-form label { display: grid; gap: .35rem; font-weight: 600; font-size: .92rem; }
.admin-form-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.admin-form .check-label { display: flex; align-items: center; gap: .5rem; }

.price-cover {
    display: block;
    margin: 0 auto 1.2rem;
    width: 170px;
    height: auto;
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
}
.price { font-size: 2.4rem; font-weight: 800; color: var(--ink); margin: .4rem 0 1rem; }
.price .muted { font-size: 1rem; font-weight: 500; }

.check-list { list-style: none; margin: 0 0 1.5rem; }
.check-list li { padding: .45rem 0 .45rem 1.9rem; position: relative; }
.check-list li::before {
    content: "✓";
    position: absolute;
    left: .2rem;
    color: var(--success);
    font-weight: 800;
}

/* ---------- FAQ ---------- */

.faq-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-top: .9rem;
    background: #fff;
    padding: 0 1.2rem;
}
.faq-item summary {
    cursor: pointer;
    font-weight: 600;
    padding: 1rem 0;
    list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; float: right; color: var(--brand); font-weight: 700; }
.faq-item[open] summary::after { content: "–"; }
.faq-item p { padding-bottom: 1rem; color: var(--ink-soft); }

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

.form-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.8rem;
    margin-top: 1.5rem;
    display: grid;
    gap: 1.1rem;
}
.form-card label { display: grid; gap: .35rem; font-weight: 600; font-size: .92rem; }
.form-card .check-row { display: flex; align-items: center; gap: .5rem; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], textarea, select {
    font-family: var(--font);
    font-size: 1rem;
    padding: .65rem .8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--ink);
    width: 100%;
}
input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
    border-color: var(--brand);
}

.profile-form { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.profile-form label { display: grid; gap: .35rem; font-weight: 600; font-size: .92rem; }
.profile-form input { width: auto; }

/* ---------- Flash messages ---------- */

.flash-stack { max-width: 1120px; margin: 1rem auto 0; padding: 0 1.25rem; display: grid; gap: .6rem; }
.flash {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border-radius: var(--radius);
    padding: .75rem 1rem;
    font-weight: 500;
    font-size: .95rem;
}
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--error-bg); color: var(--error); }
.flash-info { background: var(--info-bg); color: var(--info); }
.flash-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: inherit; }

/* ---------- App (dashboard) ---------- */

.app-body { background: var(--paper-warm); }
.app-main { padding: 2.2rem 1.25rem 3.5rem; }
.exam-countdown {
    background: #fff;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: .8rem 1.1rem;
    margin: 1rem 0 1.5rem;
}
.product-card { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.product-card .btn { margin-top: auto; }
.big-icon { font-size: 3rem; margin-bottom: .5rem; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }

/* ---------- Legal ---------- */

.legal h2 { font-size: 1.15rem; margin-top: 1.8rem; }

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

.site-footer { border-top: 1px solid var(--line); background: var(--paper-warm); padding: 3rem 0 2rem; margin-top: 2rem; }
.site-footer.slim { padding: 1.2rem 0; margin-top: 0; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; margin-bottom: 2rem; }
.footer-grid h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin-bottom: .6rem; }
.footer-grid a { display: block; color: var(--ink-soft); text-decoration: none; padding: .2rem 0; font-size: .95rem; }
.footer-grid a:hover { color: var(--ink); }
.disclaimer { border-top: 1px solid var(--line); padding-top: 1.4rem; }
.disclaimer p { font-size: .82rem; color: var(--ink-faint); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
    .hero-grid { grid-template-columns: 1fr; }
    .hero-book { margin-top: .6rem; }
    .hero-book img { max-width: 230px; transform: none; }
    .bd-grid { grid-template-columns: 1fr; gap: 1.6rem; }
    .bd-cover-col { max-width: 250px; margin: 0 auto; }
    .shelf-item { flex-direction: column; align-items: flex-start; }
    .admin-form-row { grid-template-columns: 1fr 1fr; }
    .card-grid.three { grid-template-columns: 1fr; }
    .card-grid.two { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; gap: 1.2rem; }
    .admin-stats { grid-template-columns: 1fr 1fr; }

    .nav-toggle { display: block; }
    .site-nav {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: #fff;
        border-bottom: 1px solid var(--line);
        flex-direction: column;
        align-items: stretch;
        padding: 1rem 1.25rem;
        gap: .9rem;
        box-shadow: var(--shadow-lg);
    }
    .site-nav.open { display: flex; }
    .app-body .site-nav, .admin-header .site-nav { display: flex; position: static; flex-direction: row; background: transparent; border: none; box-shadow: none; padding: 0; }
}

/* ============================================================
   Product C — pages on the app layout (book home, library,
   search, revision) + shared callout styles
   ============================================================ */

.callout {
    position: relative;
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    background: var(--paper-warm);
    padding: 1rem 1.1rem .8rem;
    margin-bottom: 1em;
}
.co-label {
    display: inline-block;
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--brand);
    margin-bottom: .35rem;
}
.callout.co-rule { border-left-color: var(--error); }
.callout.co-rule .co-label { color: var(--error); }
.callout.co-remember { border-left-color: var(--accent); }
.callout.co-remember .co-label { color: var(--accent); }
.callout.co-builder { border-left-color: var(--success); }
.callout.co-builder .co-label { color: var(--success); }
.callout.co-recap { border-left-color: var(--ink-soft); }
.callout.co-recap .co-label { color: var(--ink-soft); }
.co-jump { display: inline-block; margin-top: .4rem; text-decoration: none; }

/* ---------- Book home ---------- */

.bh-head { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; margin-bottom: 1.4rem; }
.bh-progress-ring { flex-shrink: 0; color: var(--ink); }
.bh-continue { display: flex; justify-content: space-between; align-items: center; gap: 1.2rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.bh-stats { grid-template-columns: repeat(4, 1fr); margin-bottom: 1.2rem; }
.stat-sub { font-size: .95rem; color: var(--ink-faint); font-weight: 600; }
.bh-links { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 2rem; }
.bh-toc-title { margin-bottom: .8rem; }
.bh-part { margin-bottom: 1.1rem; }
.bh-part-intro { margin: .2rem 0 .6rem; }
.bh-chapters { display: grid; gap: .15rem; margin-top: .5rem; }
.bh-chapter {
    display: grid;
    grid-template-columns: 1.4rem 1fr auto;
    grid-template-areas: "state title pct" ". bar bar";
    align-items: baseline;
    gap: 0 .5rem;
    text-decoration: none;
    color: var(--ink);
    padding: .45rem .5rem;
    border-radius: var(--radius);
}
.bh-chapter:hover { background: var(--paper-warm); }
.bhc-state { grid-area: state; color: var(--ink-faint); }
.bh-chapter.is-done .bhc-state { color: var(--success); }
.bhc-title { grid-area: title; font-size: .95rem; }
.bhc-pct { grid-area: pct; font-size: .8rem; color: var(--ink-soft); }
.bhc-bar { grid-area: bar; height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: .3rem; }
.bhc-bar span { display: block; height: 100%; background: var(--brand); }
.bh-chapter.is-todo .bhc-bar { visibility: hidden; }

/* ---------- Search ---------- */

.search-form { display: flex; gap: .6rem; margin: 1rem 0 1.5rem; }
.search-form input { flex: 1; }
.search-hit { display: block; text-decoration: none; color: var(--ink); margin-bottom: .8rem; }
.search-hit:hover { border-color: var(--brand); }
.sh-where { font-size: .82rem; font-weight: 700; color: var(--brand); margin-bottom: .3rem; }
.sh-snippet { font-size: .95rem; color: var(--ink-soft); margin: 0; }

/* ---------- Library ---------- */

.lib-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1rem 0 1.4rem; }
.lib-tab {
    text-decoration: none;
    color: var(--ink-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .4rem .9rem;
    font-size: .9rem;
    font-weight: 600;
    background: #fff;
}
.lib-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.lib-count { opacity: .75; font-weight: 500; }
.lib-item { margin-bottom: .8rem; }
.lib-link { font-weight: 600; text-decoration: none; }
.lib-note-body { margin-bottom: .4rem; }
.lib-word { font-size: 1.1rem; }
.lib-vocab-row { display: flex; gap: .7rem; align-items: center; margin-bottom: .3rem; }
.lib-vocab-actions { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .5rem; }
.lib-vocab-status.active { border-color: var(--brand); color: var(--brand); font-weight: 700; }
.badge-learning { background: var(--info-bg); color: var(--info); }
.badge-review { background: #fdf3e4; color: var(--accent); }
.badge-mastered { background: var(--success-bg); color: var(--success); }
.lib-empty { padding: 2.5rem 1.5rem; }

/* ---------- Revision ---------- */

.rev-chapter { margin: 1.6rem 0 .6rem; }
.rev-chapter a { text-decoration: none; }
.rev-hl { border-left: 4px solid var(--line); padding: .4rem .8rem; margin-bottom: .7rem; background: var(--paper-warm); border-radius: 0 var(--radius) var(--radius) 0; }
.rev-hl-yellow { border-left-color: #f5cf3f; }
.rev-hl-green { border-left-color: #59c27c; }
.rev-hl-blue { border-left-color: #5fa8ec; }
.rev-hl-pink { border-left-color: #ef7fb1; }
.rev-hl a { display: inline-block; margin-left: .4rem; text-decoration: none; }

@media (max-width: 900px) {
    .bh-stats { grid-template-columns: 1fr 1fr; }
    .bh-head { flex-direction: column-reverse; align-items: flex-start; }
}

/* ---------- Practice hub (app layout) ---------- */

.ph-skill { margin: 1.6rem 0 .2rem; font-size: 1.15rem; }
.ph-type { text-decoration: none; color: var(--ink); display: block; }
.ph-type:hover { border-color: var(--brand); }
.ph-type-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; }
.ph-acc { font-weight: 800; border-radius: 999px; padding: .2rem .6rem; font-size: .85rem; }
.ph-acc.good { background: var(--success-bg); color: var(--success); }
.ph-acc.mid { background: #fdf0e4; color: var(--accent); }
.ph-acc.low { background: var(--error-bg); color: var(--error); }
.ph-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1.2rem 0; }

/* ---------- Study plan ---------- */

.plan-day { margin-bottom: .9rem; }
.plan-today { border-color: var(--brand); border-width: 2px; }
.plan-task { display: flex; gap: .55rem; align-items: baseline; padding: .28rem 0; }
.plan-task.done label, .plan-task.done a { text-decoration: line-through; color: var(--ink-faint); }
.plan-task a { text-decoration: none; }
.plan-check { accent-color: var(--brand); }
.prep-page h2 { margin-top: 1.6rem; }

.mono { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
