/* =============================================================================
 * SimPath Academy — style.css
 * Single source of visual truth. Every page links this file.
 * No inline styles. No component-level CSS files that contradict this.
 * Architecture ref: §9 Style Guide
 * Last Updated: 2026-05-15
 * ============================================================================= */

/* --- Custom Properties (locked palette) ------------------------------------ */
:root {
    --color-bg:           #FFFFFF;
    --color-bg-alt:       #F7F8FA;
    --color-text-primary: #0A0A0A;
    --color-text-secondary: #444A52;
    --color-accent-blue:  #1B3A57;
    --color-accent-teal:  #2E8A87;
    --color-accent-gold:  #B89556;
    --color-success:      #3A7D44;
    --color-warning:      #B5731C;
    --color-error:        #9E2B2B;
    --color-border:       #D1D5DB;
    --color-border-light: #E5E7EB;

    --font-body:    'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', 'Menlo', 'Consolas', monospace;
    --font-size-base: 1rem;
    --font-size-md:   1rem;     /* alias of base; templates already reference this name */
    --font-size-sm:   0.875rem;
    --font-size-lg:   1.125rem;
    --font-size-xl:   1.25rem;
    --font-size-2xl:  1.5rem;
    --font-size-3xl:  1.875rem;
    --line-height-base: 1.6;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;
    --space-16: 4rem;

    --max-width: 1200px;
    --content-width: 800px;

    --radius-sm:  4px;
    --radius-md:  8px;
    --radius-lg:  12px;
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg:  0 8px 24px rgba(0,0,0,0.12);
    --transition: 150ms ease;
}

/* --- Reset ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
    color: var(--color-text-primary);
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--color-accent-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }

/* --- Typography ------------------------------------------------------------ */
h1 { font-size: var(--font-size-3xl); font-weight: 700; line-height: 1.2; }
h2 { font-size: var(--font-size-2xl); font-weight: 600; line-height: 1.3; }
h3 { font-size: var(--font-size-xl);  font-weight: 600; line-height: 1.4; }
h4 { font-size: var(--font-size-lg);  font-weight: 600; }
h5, h6 { font-size: var(--font-size-base); font-weight: 600; }

p + p { margin-top: var(--space-4); }
strong { font-weight: 600; }
code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border-light);
    padding: 0.1em 0.3em;
    border-radius: var(--radius-sm);
}

/* --- Layout ---------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-6);
}
.content-width {
    max-width: var(--content-width);
    margin: 0 auto;
}
.site-main {
    flex: 1;
    padding: var(--space-8) 0;
}

/* --- Header ---------------------------------------------------------------- */
.site-header {
    background: var(--color-accent-blue);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}
.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-6);
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-8);
}
.site-logo { display: flex; align-items: center; gap: var(--space-3); }
.logo-text {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}
.logo-text:hover { text-decoration: none; opacity: 0.9; }
.site-nav { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.nav-link {
    color: rgba(255,255,255,0.85);
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.12); text-decoration: none; }
.nav-link--active { color: #fff; background: rgba(255,255,255,0.15); }
.nav-link--logout { color: rgba(255,255,255,0.65); }
.nav-user {
    font-size: var(--font-size-sm);
    color: rgba(255,255,255,0.65);
    font-weight: 500;
}

/* --- Footer ---------------------------------------------------------------- */
.site-footer {
    background: var(--color-bg-alt);
    border-top: 1px solid var(--color-border);
    padding: var(--space-8) 0;
    margin-top: auto;
}
.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-6);
    text-align: center;
}
.footer-copy { font-size: var(--font-size-sm); color: var(--color-text-secondary); }
.footer-meta { font-size: var(--font-size-sm); color: var(--color-text-secondary); margin-top: var(--space-2); }
.footer-meta a { color: var(--color-text-secondary); }
.footer-meta a:hover { color: var(--color-accent-blue); }
.footer-version { font-size: 0.8rem; opacity: 0.6; }

/* --- Buttons --------------------------------------------------------------- */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    transition: opacity var(--transition), background var(--transition), box-shadow var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}
.btn-primary  { background: var(--color-accent-blue); color: #fff; }
.btn-primary:hover { opacity: 0.88; text-decoration: none; color: #fff; }
.btn-secondary { background: transparent; color: var(--color-accent-blue); border: 2px solid var(--color-accent-blue); }
.btn-secondary:hover { background: var(--color-accent-blue); color: #fff; text-decoration: none; }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-danger:hover { opacity: 0.88; text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.btn-ghost:hover { background: var(--color-bg-alt); text-decoration: none; }
.btn-sm { padding: var(--space-2) var(--space-4); font-size: 0.8rem; }
.btn-lg { padding: var(--space-4) var(--space-8); font-size: var(--font-size-base); }
button:disabled, .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Forms ----------------------------------------------------------------- */
.form-group { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-6); }
.form-label { font-size: var(--font-size-sm); font-weight: 600; color: var(--color-text-primary); }
.form-label--required::after { content: ' *'; color: var(--color-error); }
.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-base);
    font-family: var(--font-body);
    color: var(--color-text-primary);
    background: var(--color-bg);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-accent-teal);
    box-shadow: 0 0 0 3px rgba(46,138,135,0.15);
}
.form-textarea { resize: vertical; min-height: 120px; }
.form-hint { font-size: var(--font-size-sm); color: var(--color-text-secondary); }
.form-error { font-size: var(--font-size-sm); color: var(--color-error); }

/* --- Cards ----------------------------------------------------------------- */
.card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
}
.card + .card { margin-top: var(--space-4); }
.card-title { font-size: var(--font-size-lg); font-weight: 600; margin-bottom: var(--space-3); }
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-6);
}

/* --- Alerts ---------------------------------------------------------------- */
.alert {
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-6);
}
.alert-success { background: #f0faf1; border-color: var(--color-success); color: #1e4d26; }
.alert-error   { background: #fdf2f2; border-color: var(--color-error);   color: #5c1a1a; }
.alert-warning { background: #fdf8ee; border-color: var(--color-warning); color: #6b3e0a; }
.alert-info    { background: #eef4fb; border-color: var(--color-accent-blue); color: #12263f; }

/* --- Tables ---------------------------------------------------------------- */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
.data-table th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-alt);
    border-bottom: 2px solid var(--color-border);
    font-weight: 600;
    white-space: nowrap;
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}
.data-table tr:hover td { background: var(--color-bg-alt); }
.data-table tr:last-child td { border-bottom: none; }

/* --- Badges ---------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-2);
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-error   { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: var(--color-bg-alt); color: var(--color-text-secondary); border: 1px solid var(--color-border); }

/* --- Page header block ----------------------------------------------------- */
.page-header { margin-bottom: var(--space-8); }
.page-header h1 { font-size: var(--font-size-2xl); }
.page-header p { color: var(--color-text-secondary); margin-top: var(--space-2); }

/* --- Utility --------------------------------------------------------------- */
.text-secondary { color: var(--color-text-secondary); }
.text-sm { font-size: var(--font-size-sm); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; justify-content: center; align-items: center; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.hidden { display: none; }
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

/* --- Progress bar ---------------------------------------------------------- */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: 99px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--color-accent-teal);
    border-radius: 99px;
    transition: width 0.3s ease;
}

/* --- Loading spinner ------------------------------------------------------- */
.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent-teal);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }

/* ============================================================================
 * ===== CALLOUT DESIGN SYSTEM =====
 * Lesson-body content blocks. Mirrors the .alert border-left pattern but
 * scoped semantically for instructional content (concept / definition /
 * example / exam-hint / important / case-study). Each variant sets
 * --callout-icon (read by .callout > p:first-child::before) and tints
 * the background + left border with palette tokens where available,
 * literal hex where the palette doesn't carry the hue (purple, teal-tint).
 *
 * Used by lesson.php (.lo-text-body wrapper) and by AI-formatted body
 * content emitted from admin/lore/format-content.php.
 * ============================================================================ */
.callout {
    border-left: 4px solid;
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-6);
    margin: var(--space-6) 0;
}
/* Inject the icon at the start of the first paragraph so it sits inline with
   the leading <strong> label, instead of awkwardly stacking above a block
   child. content: "" fallback keeps the rule safe if a variant forgets to
   set --callout-icon. */
.callout > p:first-child::before {
    content: var(--callout-icon, "");
    margin-right: 0.4em;
}
.callout > p:first-child { margin-top: 0; }
.callout > p:last-child  { margin-bottom: 0; }

.callout-concept {
    --callout-icon: "💡";
    border-left-color: var(--color-accent-blue);
    background: #eef4fb;
}
.callout-definition {
    --callout-icon: "📖";
    border-left-color: #6b46c1;       /* purple — not in palette, intentional literal */
    background: #f3eefb;
}
.callout-example {
    --callout-icon: "🔍";
    border-left-color: var(--color-success);
    background: #f0faf1;
}
.callout-exam-hint {
    --callout-icon: "🎯";
    border-left-color: var(--color-warning);
    background: #fdf8ee;
}
.callout-important {
    --callout-icon: "⚠️";
    border-left-color: var(--color-error);
    background: #fdf2f2;
}
.callout-case-study {
    --callout-icon: "🏢";
    border-left-color: var(--color-accent-teal);
    background: #e8f3f3;
}

/* ============================================================================
 * ===== LO TEXT BODY PROSE =====
 * Typography for text-type Learning Object bodies rendered in the lesson
 * viewer. Scoped to .lo-text-body so it never bleeds onto admin/form/dash
 * surfaces. The base reset turns ul/ol into list-style:none — we restore
 * the markers here because prose lists are semantically lists, not nav.
 * ============================================================================ */
.lo-text-body {
    font-size: var(--font-size-md);
    line-height: 1.75;
    color: var(--color-text-primary);
}
.lo-text-body h2 {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    line-height: 1.2;
    margin-top: var(--space-8);
    margin-bottom: var(--space-3);
}
.lo-text-body h2:first-child { margin-top: 0; }
.lo-text-body h3 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    line-height: 1.3;
    margin-top: var(--space-6);
    margin-bottom: var(--space-2);
}
.lo-text-body p { margin-bottom: var(--space-4); }
.lo-text-body ul,
.lo-text-body ol {
    padding-left: 1.5em;
    margin-bottom: var(--space-4);
}
.lo-text-body ul { list-style: disc; }
.lo-text-body ol { list-style: decimal; }
.lo-text-body li { margin-bottom: var(--space-2); }
.lo-text-body code {
    background: var(--color-bg-alt);
    padding: 0.1em 0.35em;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.88em;
}
.lo-text-body blockquote {
    border-left: 3px solid var(--color-border);
    margin: var(--space-4) 0;
    padding: var(--space-3) var(--space-4);
    color: var(--color-text-secondary);
    font-style: italic;
}
.lo-text-body strong { font-weight: 700; }
.lo-text-body em     { font-style: italic; }
/* Callouts inside .lo-text-body — inherit the global .callout rules above. */

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 768px) {
    .header-inner { height: auto; padding: var(--space-4) var(--space-4); flex-wrap: wrap; }
    .site-nav { gap: var(--space-2); }
    .container { padding: 0 var(--space-4); }
    .card-grid { grid-template-columns: 1fr; }
    h1 { font-size: var(--font-size-2xl); }
    h2 { font-size: var(--font-size-xl); }
}
