/* =============================================================================
   Peter Bassill personal site — theme stylesheet
   Three themes: light, dark (default), and VT100. Selected via the
   data-theme attribute on <html>, set server-side from the pb_theme cookie
   (and toggled client-side via theme-switcher.js).
   ============================================================================= */

:root {
    --accent:        #00ff88;
    --accent-soft:   rgba(0, 255, 136, 0.15);
    --bg:            #0b0d12;
    --bg-elev:       #11141b;
    --bg-card:       #161a23;
    --fg:            #e6edf3;
    --fg-muted:      #9aa4b2;
    --fg-dim:        #6b7280;
    --border:        #1f2937;
    --link:          #4ade80;
    --link-hover:    #86efac;
    --danger:        #f87171;
    --warning:       #fbbf24;
    --success:       #34d399;

    --radius:        10px;
    --radius-sm:     6px;

    --font-body:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display:  var(--font-body);
    --font-mono:     "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

    --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.20);
    --shadow:        0 6px 24px rgba(0, 0, 0, 0.30);
}

/* ------- Light theme ------- */
html[data-theme="light"] {
    --accent:        #047857;
    --accent-soft:   rgba(4, 120, 87, 0.10);
    --bg:            #fbfbfc;
    --bg-elev:       #ffffff;
    --bg-card:       #ffffff;
    --fg:            #111827;
    --fg-muted:      #4b5563;
    --fg-dim:        #6b7280;
    --border:        #e5e7eb;
    --link:          #047857;
    --link-hover:    #065f46;
    --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow:        0 6px 24px rgba(0, 0, 0, 0.08);
}

/* ------- Dark theme (default; explicit for clarity) ------- */
html[data-theme="dark"] {
    --accent:        #00ff88;
    --accent-soft:   rgba(0, 255, 136, 0.15);
    --bg:            #0b0d12;
    --bg-elev:       #11141b;
    --bg-card:       #161a23;
    --fg:            #e6edf3;
    --fg-muted:      #9aa4b2;
    --fg-dim:        #6b7280;
    --border:        #1f2937;
    --link:          #4ade80;
    --link-hover:    #86efac;
}

/* ------- VT100 terminal theme ------- */
html[data-theme="vt100"] {
    --accent:        #33ff33;
    --accent-soft:   rgba(51, 255, 51, 0.12);
    --bg:            #001100;
    --bg-elev:       #001a00;
    --bg-card:       #001a00;
    --fg:            #33ff33;
    --fg-muted:      #1aaa1a;
    --fg-dim:        #0e7c0e;
    --border:        #0e7c0e;
    --link:          #66ff66;
    --link-hover:    #ccffcc;

    --font-body:     "VT323", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    --font-display:  var(--font-body);
    --font-mono:     var(--font-body);
}

html[data-theme="vt100"] body {
    text-shadow: 0 0 1px rgba(51, 255, 51, 0.6);
}

html[data-theme="vt100"] .navbar,
html[data-theme="vt100"] .card,
html[data-theme="vt100"] .form-control {
    border-radius: 0;
}

/* CRT scanline overlay — purely cosmetic, ignored by reduced-motion users. */
html[data-theme="vt100"] body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0,0,0,0) 0,
        rgba(0,0,0,0) 2px,
        rgba(0,0,0,0.10) 3px,
        rgba(0,0,0,0) 4px
    );
    mix-blend-mode: multiply;
}

@media (prefers-reduced-motion: reduce) {
    html[data-theme="vt100"] body::before { display: none; }
}

/* ------- Base ------- */
html, body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main { flex: 1 0 auto; }

a { color: var(--link); text-decoration: none; transition: color .15s ease; }
a:hover, a:focus-visible { color: var(--link-hover); text-decoration: underline; }
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

::selection { background: var(--accent-soft); color: var(--fg); }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--fg);
    letter-spacing: -0.01em;
}

code, pre, kbd, samp { font-family: var(--font-mono); }

pre {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

/* ------- Bootstrap overrides ------- */
.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #051811;
    font-weight: 600;
}
.btn-primary:hover, .btn-primary:focus-visible {
    background: var(--link-hover);
    border-color: var(--link-hover);
    color: #051811;
}
.btn-outline-primary {
    color: var(--accent);
    border-color: var(--accent);
}
.btn-outline-primary:hover {
    background: var(--accent);
    color: #051811;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
}

.card-title { color: var(--fg); }
.text-muted, .text-secondary { color: var(--fg-muted) !important; }

.form-control, .form-select {
    background: var(--bg-elev);
    color: var(--fg);
    border: 1px solid var(--border);
}
.form-control:focus, .form-select:focus {
    background: var(--bg-elev);
    color: var(--fg);
    border-color: var(--accent);
    box-shadow: 0 0 0 0.20rem var(--accent-soft);
}
.form-control::placeholder { color: var(--fg-dim); }

table { color: var(--fg); }
.table { color: var(--fg); --bs-table-bg: transparent; }
.table > :not(caption) > * > * { background: transparent; color: var(--fg); border-bottom-color: var(--border); }

hr { border-color: var(--border); }

/* ------- Navbar ------- */
.navbar {
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    padding-top: .75rem;
    padding-bottom: .75rem;
}
.navbar .navbar-brand {
    font-weight: 700;
    color: var(--fg);
    letter-spacing: -.01em;
}
.navbar .navbar-brand .accent { color: var(--accent); }
.navbar .nav-link {
    color: var(--fg-muted);
    font-weight: 500;
    padding: .35rem .9rem;
    border-radius: var(--radius-sm);
}
.navbar .nav-link:hover, .navbar .nav-link.active {
    color: var(--fg);
    background: var(--accent-soft);
}
.navbar-toggler { border-color: var(--border); }
.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(154, 164, 178, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ------- Hero ------- */
.hero {
    padding: 5rem 0 4rem;
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.hero::after {
    content: "";
    position: absolute;
    inset: -50% -10% auto auto;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(closest-side, var(--accent-soft), transparent 70%);
    pointer-events: none;
    z-index: 0;
}
.hero > .container { position: relative; z-index: 1; }
.hero h1 {
    font-size: clamp(2.2rem, 5vw, 3.6rem);
    line-height: 1.1;
    margin-bottom: 1rem;
}
.hero .lead { color: var(--fg-muted); max-width: 60ch; }
.hero .accent { color: var(--accent); }

/* ------- Cards / sections ------- */
.section { padding: 4rem 0; }
.section-eyebrow {
    text-transform: uppercase;
    letter-spacing: .14em;
    font-size: .75rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: .75rem;
}
.section-title { font-size: clamp(1.6rem, 3.2vw, 2.2rem); margin-bottom: 2rem; }

.card-link { color: inherit; text-decoration: none; display: block; height: 100%; }
.card-link:hover { text-decoration: none; }
.card-link:hover .card { border-color: var(--accent); transform: translateY(-2px); transition: all .15s ease; }
.card .card-body { padding: 1.5rem; }
.card .tagline { color: var(--accent); font-weight: 600; font-size: .875rem; }

/* ------- Skills grid ------- */
.skills-category { margin-bottom: 2rem; }
.skill-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: .75rem 0;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}
.skill-row .skill-name { font-weight: 600; }
.skill-row .skill-summary { color: var(--fg-muted); font-size: .9rem; }
.skill-meter {
    display: inline-flex; gap: 4px; align-items: center;
}
.skill-meter span {
    width: 10px; height: 10px; border-radius: 2px;
    background: var(--border);
}
.skill-meter span.on { background: var(--accent); }

/* ------- Experience timeline ------- */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
    content: "";
    position: absolute; left: .35rem; top: 0; bottom: 0; width: 2px;
    background: var(--border);
}
.timeline .entry { position: relative; padding-bottom: 2rem; }
.timeline .entry::before {
    content: "";
    position: absolute; left: -1.4rem; top: .35rem;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}
.timeline .entry h3 { margin-bottom: .25rem; font-size: 1.15rem; }
.timeline .entry .meta { color: var(--fg-muted); font-size: .9rem; margin-bottom: .5rem; }

/* ------- Footer ------- */
footer.site-footer {
    border-top: 1px solid var(--border);
    color: var(--fg-muted);
    padding: 2rem 0;
    margin-top: 3rem;
    font-size: .9rem;
}
footer.site-footer a { color: var(--fg-muted); }
footer.site-footer a:hover { color: var(--fg); }

/* ------- Theme switcher ------- */
.theme-switcher {
    display: inline-flex;
    gap: .25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
}
.theme-switcher button {
    background: transparent;
    color: var(--fg-muted);
    border: 0;
    padding: .35rem .6rem;
    border-radius: 4px;
    font-size: .8rem;
    cursor: pointer;
}
.theme-switcher button:hover { color: var(--fg); }
.theme-switcher button[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent);
}

/* ------- Tags / pills ------- */
.tag {
    display: inline-block; padding: .15rem .55rem;
    border: 1px solid var(--border); border-radius: 999px;
    font-size: .75rem; color: var(--fg-muted);
    margin-right: .35rem; margin-bottom: .35rem;
}

/* ------- Project detail page ------- */
.project-hero {
    padding: 3rem 0; border-bottom: 1px solid var(--border);
}
.project-hero .tagline { color: var(--accent); font-weight: 600; }

/* ------- Blog ------- */
.post-list .post { padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.post-list .post:last-child { border-bottom: 0; }
.post-list .post h3 { margin-bottom: .25rem; font-size: 1.25rem; }
.post-meta { color: var(--fg-muted); font-size: .85rem; }

article.post-body h2 { margin-top: 2rem; }
article.post-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
article.post-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--fg-muted);
}

/* ------- Admin ------- */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 240px; flex-shrink: 0;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    padding: 1rem 0;
}
.admin-sidebar a {
    display: block; padding: .55rem 1.25rem;
    color: var(--fg-muted); border-left: 3px solid transparent;
}
.admin-sidebar a.active, .admin-sidebar a:hover {
    color: var(--fg); border-left-color: var(--accent);
    background: var(--accent-soft);
    text-decoration: none;
}
.admin-main { flex: 1; padding: 2rem; max-width: 100%; }
.admin-topbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 2rem; padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.alert-soft {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    color: var(--fg);
    border-radius: var(--radius-sm);
    padding: .75rem 1rem;
}

/* ------- Utility ------- */
.text-accent { color: var(--accent); }
.bg-card { background: var(--bg-card); }
.border-soft { border: 1px solid var(--border); }
.kbd-shortcut {
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    font-family: var(--font-mono);
    font-size: .8em;
}
