/* Shared base styles. Customer-facing pages (index.php, purchase.php, manage.php)
   use this alone; admin pages add css/admin.css on top. */

:root {
    --navy: #0f2742;
    --navy-2: #1b3d66;
    --accent: #1f6fd1;
    --accent-hover: #1858a8;
    --bg: #f3f6fa;
    --card: #ffffff;
    --text: #1f2933;
    --muted: #5f6b7a;
    --border: #dfe5ec;
    --success-bg: #e8f5ee;
    --success: #1d6b45;
    --warn-bg: #fff6e5;
    --warn: #8a5300;
    --danger-bg: #fdecec;
    --danger: #a82020;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15, 39, 66, 0.06), 0 4px 16px rgba(15, 39, 66, 0.06);
}

*, *::before, *::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 400 17px/1.6 'Source Sans 3', 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    color: var(--accent-hover);
}

h1, h2, h3 {
    color: var(--navy);
    line-height: 1.25;
    margin: 0 0 0.5em;
}

h1 { font-size: 1.9rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }

p {
    margin: 0 0 1em;
}

/* ---------- Header / footer ---------- */

.site-header {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
    color: #fff;
}

.site-header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
}

.brand:hover {
    color: #fff;
}

.brand img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
}

.brand-name {
    display: block;
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1.2;
}

.brand-sub {
    display: block;
    font-size: 0.8rem;
    opacity: 0.75;
    letter-spacing: 0.02em;
}

.site-nav a {
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    white-space: nowrap;
}

.site-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

main {
    flex: 1;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 48px;
}

main.narrow {
    max-width: 720px;
}

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--card);
    color: var(--muted);
    font-size: 0.875rem;
}

.site-footer-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
}

/* ---------- Building blocks ---------- */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 24px;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.875rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    padding: 14px 24px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.btn:hover {
    background: var(--accent-hover);
    color: #fff;
}

.btn:focus-visible,
.faq summary:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(31, 111, 209, 0.35);
    outline-offset: 2px;
}

.btn-lg {
    font-size: 1.1rem;
    padding: 16px 28px;
}

.btn-block {
    width: 100%;
}

.btn-secondary {
    background: var(--card);
    color: var(--navy);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
    color: var(--navy);
}

.alert {
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert p:last-child {
    margin-bottom: 0;
}

.alert strong:first-child {
    display: block;
    margin-bottom: 2px;
}

.alert-success { background: var(--success-bg); color: var(--success); border-color: #c4e5d3; }
.alert-warn    { background: var(--warn-bg);    color: var(--warn);    border-color: #f3dcae; }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: #f3c6c6; }
.alert-info    { background: #eaf2fc;           color: var(--navy-2);  border-color: #cadcf4; }

.alert a {
    color: inherit;
    font-weight: 600;
}

.badge {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: #eaf2fc;
    color: var(--navy-2);
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-muted   { background: #eef1f4;           color: var(--muted); }

/* ---------- Store (index.php without a token) ---------- */

.product {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 36px;
    align-items: center;
    padding: 32px;
}

.product-image {
    border-radius: 8px;
    border: 1px solid var(--border);
    width: 100%;
}

.product h1 {
    margin: 12px 0 0.35em;
}

.product-lede {
    color: var(--muted);
    font-size: 1.05rem;
}

.checklist {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
}

.checklist li {
    position: relative;
    padding-left: 28px;
    margin-bottom: 8px;
}

.checklist li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 0.4em;
    width: 14px;
    height: 8px;
    border-left: 2.5px solid var(--success);
    border-bottom: 2.5px solid var(--success);
    transform: rotate(-45deg);
}

.buy-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.price {
    font-size: 2rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1;
}

.secure-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 0.85rem;
    color: var(--muted);
}

.secure-note img {
    height: 16px;
    width: auto;
    opacity: 0.8;
}

.already-bought {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 24px;
}

.already-bought p {
    margin: 0;
}

/* ---------- Download page ---------- */

.download-hero {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 28px;
    align-items: center;
}

.download-hero img {
    border-radius: 8px;
    border: 1px solid var(--border);
}

.download-hero img.is-expired {
    filter: grayscale(1);
    opacity: 0.55;
}

.signature {
    font-style: italic;
    color: var(--muted);
}

.details {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 10px 24px;
    margin: 0;
}

.details dt {
    color: var(--muted);
}

.details dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.details.spaced {
    margin-bottom: 24px;
}

.back-link {
    margin: 16px 0 0;
    text-align: center;
}

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

.form-field {
    margin-bottom: 18px;
}

.form-field label {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.form-field .hint {
    font-weight: 400;
    color: var(--muted);
}

.form-field input {
    width: 100%;
    font: inherit;
    padding: 11px 14px;
    border: 1px solid #c9d2dc;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 209, 0.2);
}

.or-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 4px 0 18px;
}

.or-divider::before,
.or-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

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

.faq details {
    border-top: 1px solid var(--border);
}

.faq details:last-child {
    border-bottom: 1px solid var(--border);
}

.faq summary {
    list-style: none;
    cursor: pointer;
    padding: 16px 36px 16px 0;
    font-weight: 600;
    color: var(--navy);
    position: relative;
}

.faq summary::-webkit-details-marker {
    display: none;
}

.faq summary::after {
    content: "+";
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--muted);
    transition: transform 0.2s ease;
}

.faq details[open] summary::after {
    transform: translateY(-50%) rotate(45deg);
}

.faq details p {
    color: var(--muted);
    margin: 0 0 18px;
    padding-right: 36px;
}

/* ---------- Small screens ---------- */

@media (max-width: 720px) {
    main {
        padding: 20px 16px 36px;
    }

    .card,
    .product {
        padding: 20px;
    }

    .product,
    .download-hero {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .download-hero img {
        max-width: 280px;
    }

    h1 { font-size: 1.6rem; }

    .brand-sub {
        display: none;
    }

    .buy-row .btn {
        flex: 1;
    }
}
