/* ─────────────────────────────────────────────────────────────
   Sabiedu design system — shared across sabiedu / books / learn.
   Flat, minimal, engineered. One accent. No gradients or glow.

   Deliberately keeps the LEGACY variable names (--primary, --bg,
   --surface, --text-primary, --text-secondary, --border) so the
   existing Tailwind markup (bg-[var(--surface)] etc.) inherits the
   new palette without a rewrite, while new markup can use the
   richer tokens and component classes below.

   Per-app accent is set at the bottom via [data-app].
   ───────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@500;600;700&family=Inter:wght@400;450;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    /* ── surfaces ── */
    --bg: #ffffff;
    --bg-subtle: #fafafa;
    --surface: #ffffff;
    --surface-sunk: #f7f7f8;
    --border: #ececec;
    --border-strong: #dadada;

    /* ── ink ── */
    --ink: #0a0a0a;
    --muted: #6b7280;
    --faint: #9ca3af;

    /* ── accent ── */
    --accent: #2348ff;
    --accent-ink: #ffffff;
    --accent-soft: rgba(35, 72, 255, 0.07);
    --accent-line: rgba(35, 72, 255, 0.22);

    /* ── status ── */
    --ok-bg: #ecfdf3;
    --ok-fg: #027a48;
    --err-bg: #fef3f2;
    --err-fg: #b42318;
    --warn-bg: #fffaeb;
    --warn-fg: #b54708;

    /* ── shape & motion ── */
    --radius: 12px;
    --radius-sm: 9px;
    --radius-lg: 18px;
    --maxw: 1120px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 1px 2px rgba(10, 10, 10, 0.04);
    --shadow: 0 4px 16px -4px rgba(10, 10, 10, 0.08), 0 2px 6px -2px rgba(10, 10, 10, 0.04);
    --shadow-lg: 0 18px 40px -12px rgba(10, 10, 10, 0.16);

    /* ── type ── */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --display: 'Inter Tight', var(--font);
    --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;

    /* ── legacy aliases (existing markup depends on these) ── */
    --primary: var(--accent);
    --primary-hover: #1b39d6;
    --neutral: var(--faint);
    --text-primary: var(--ink);
    --text-secondary: var(--muted);
    --success: var(--ok-fg);
    --warning: var(--warn-fg);
    --error: var(--err-fg);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0a0b;
        --bg-subtle: #0f0f12;
        --surface: #121215;
        --surface-sunk: #17171b;
        --border: #232327;
        --border-strong: #2e2e34;

        --ink: #f4f4f5;
        --muted: #a1a1aa;
        --faint: #71717a;

        --accent: #6f8bff;
        --accent-ink: #0a0a0b;
        --accent-soft: rgba(111, 139, 255, 0.10);
        --accent-line: rgba(111, 139, 255, 0.28);

        --ok-bg: rgba(5, 150, 105, 0.14);
        --ok-fg: #4ade80;
        --err-bg: rgba(220, 38, 38, 0.14);
        --err-fg: #f87171;
        --warn-bg: rgba(180, 83, 9, 0.16);
        --warn-fg: #fbbf24;

        --primary-hover: #8ba3ff;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 18px 40px -12px rgba(0, 0, 0, 0.7);
    }
}

/* ── base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
::selection { background: var(--accent); color: var(--accent-ink); }

h1, h2, h3, h4 {
    font-family: var(--display);
    letter-spacing: -0.021em;
    line-height: 1.15;
    margin: 0;
}

/* Tailwind's font-bold on a display face is too heavy at large sizes. */
h1 { font-weight: 700; }
h2, h3 { font-weight: 600; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── eyebrow ────────────────────────────────────────────────── */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ── buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font);
    font-size: 14.5px;
    font-weight: 550;
    line-height: 1;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
                color 0.18s var(--ease), transform 0.06s var(--ease), box-shadow 0.18s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.07); box-shadow: var(--shadow); }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); background: var(--bg-subtle); }

.btn-sm { padding: 9px 14px; font-size: 13.5px; }
.btn-lg { padding: 15px 26px; font-size: 15.5px; }
.btn-block { width: 100%; }

/* ── nav ────────────────────────────────────────────────────── */
.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(1.2) blur(10px);
    border-bottom: 1px solid var(--border);
}
.nav-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 24px;
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand {
    font-family: var(--display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.03em;
    color: var(--ink);
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.navlink {
    font-size: 14px;
    color: var(--muted);
    padding: 8px 12px;
    border-radius: 8px;
    transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.navlink:hover { color: var(--ink); background: var(--bg-subtle); }
.navlink.is-active { color: var(--ink); font-weight: 550; }

/* ── layout ─────────────────────────────────────────────────── */
/* NOT named .container: the Tailwind CDN defines its own .container and loads
   after this file, so ours would lose the cascade and content would sit flush
   against the viewport edge. */
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
/* Vertical only: these classes are combined with .wrap, and a `padding`
   shorthand would reset its horizontal padding to 0. */
.section { padding-top: 72px; padding-bottom: 72px; }
.section-head { margin-bottom: 40px; }
.section-title { font-size: clamp(26px, 3.4vw, 34px); font-weight: 600; }
.section-desc { color: var(--muted); margin-top: 10px; max-width: 62ch; }

/* ── hero ───────────────────────────────────────────────────── */
.hero { padding-top: 92px; padding-bottom: 64px; }
.hero-title {
    font-size: clamp(38px, 6.2vw, 62px);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.04;
    margin: 18px 0 0;
}
.hero-sub {
    font-size: clamp(16px, 1.7vw, 19px);
    color: var(--muted);
    max-width: 58ch;
    margin: 20px 0 0;
    line-height: 1.6;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }

/* ── cards & grids ──────────────────────────────────────────── */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
}
.card-hover:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

/* ── product / book card ────────────────────────────────────── */
.pcard { display: flex; flex-direction: column; overflow: hidden; height: 100%; }
.pcard-media {
    position: relative;
    background: var(--surface-sunk);
    border-bottom: 1px solid var(--border);
    padding: 22px 22px 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.pcard-media img {
    width: 78%;
    aspect-ratio: 2 / 3;
    object-fit: contain;
    object-position: bottom;
    border-radius: 3px 8px 8px 3px;
    box-shadow: var(--shadow-lg);
    transition: transform 0.28s var(--ease);
}
.card-hover:hover .pcard-media img { transform: translateY(-4px) rotate(-0.6deg); }
.pcard-media.is-empty {
    aspect-ratio: 16 / 10;
    align-items: center;
    padding: 0;
    color: var(--faint);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.pcard-body { padding: 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.pcard-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.pcard-meta { font-size: 13px; color: var(--muted); }
.pcard-desc {
    font-size: 14px;
    color: var(--muted);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.pcard-foot {
    margin-top: auto;
    padding-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.price { font-family: var(--display); font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.price-free { color: var(--ok-fg); }

/* ── badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 4px 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    background: var(--bg-subtle);
    white-space: nowrap;
}
.badge-accent { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.badge-ok { color: var(--ok-fg); border-color: transparent; background: var(--ok-bg); }
.badge-owned::before { content: '✓'; font-family: var(--font); }

/* ── forms ──────────────────────────────────────────────────── */
.input, .select, .textarea {
    width: 100%;
    font-family: var(--font);
    font-size: 15px;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.label {
    display: block;
    font-size: 13px;
    font-weight: 550;
    color: var(--ink);
    margin-bottom: 7px;
}
.field { margin-bottom: 16px; }
.hint { font-size: 12.5px; color: var(--faint); margin-top: 6px; }

/* ── auth / panel ───────────────────────────────────────────── */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-sm);
}
.panel-narrow { max-width: 420px; margin: 0 auto; }

/* ── notices ────────────────────────────────────────────────── */
.notice { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 14px; }
.notice-ok { background: var(--ok-bg); color: var(--ok-fg); }
.notice-err { background: var(--err-bg); color: var(--err-fg); }
.notice-warn { background: var(--warn-bg); color: var(--warn-fg); }

/* ── empty state ────────────────────────────────────────────── */
.empty {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 56px 28px;
    text-align: center;
    color: var(--muted);
}

/* ── footer ─────────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--border); margin-top: 80px; padding: 32px 0; }
.footer-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: 13.5px;
    color: var(--muted);
}
.footer-links { display: flex; gap: 20px; }
.footer-links a:hover { color: var(--ink); }

/* ── reading surface (books) ────────────────────────────────── */
.prose {
    font-family: var(--serif);
    font-size: 18.5px;
    line-height: 1.75;
    color: var(--ink);
    max-width: 72ch;
}
.prose h1, .prose h2, .prose h3 { font-family: var(--display); margin: 2em 0 0.6em; }
.prose h2 { font-size: 1.5em; }
.prose h3 { font-size: 1.2em; }
.prose p { margin: 0 0 1.15em; }
.prose ul, .prose ol { margin: 0 0 1.15em; padding-left: 1.4em; }
.prose li { margin-bottom: 0.4em; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.prose blockquote {
    margin: 1.6em 0;
    padding: 2px 0 2px 20px;
    border-left: 2px solid var(--accent-line);
    color: var(--muted);
    font-style: italic;
}
.prose code {
    font-family: var(--mono);
    font-size: 0.86em;
    background: var(--surface-sunk);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1.5px 5px;
}
.prose pre {
    font-family: var(--mono);
    font-size: 13.5px;
    line-height: 1.65;
    background: var(--surface-sunk);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    overflow-x: auto;
    margin: 1.5em 0;
}
.prose pre code { background: none; border: none; padding: 0; font-size: inherit; }
.prose img { border-radius: var(--radius); margin: 1.6em 0; }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2.4em 0; }

/* ── per-app accent ─────────────────────────────────────────── */
[data-app="books"] { --accent: #1f5fd8; --primary-hover: #184ead; }
[data-app="learn"] { --accent: #2348ff; --primary-hover: #1b39d6; }
@media (prefers-color-scheme: dark) {
    [data-app="books"] { --accent: #7aa5ff; }
    [data-app="learn"] { --accent: #6f8bff; }
}

/* ── motion preference ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── purchase page (books) ──────────────────────────────────── */
.buy-wrap {
    display: grid;
    grid-template-columns: minmax(220px, 320px) 1fr;
    gap: 56px;
    align-items: start;
}
@media (max-width: 860px) {
    .buy-wrap { grid-template-columns: 1fr; gap: 32px; }
    .buy-cover { max-width: 240px; }
}
.buy-cover img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: contain;
    border-radius: 4px 12px 12px 4px;
    box-shadow: var(--shadow-lg);
}
.buy-cover-empty {
    width: 100%;
    aspect-ratio: 2 / 3;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--faint);
    font-family: var(--mono);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.buy-perks { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 10px; }
.buy-perks li {
    position: relative;
    padding-left: 26px;
    font-size: 14.5px;
    color: var(--muted);
}
.buy-perks li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: -1px;
    color: var(--ok-fg);
    font-weight: 600;
}
