/* ==========================================================================
   Charles S. Carreon — Portfolio styles
   Dark theme by default; light theme via html[data-theme="light"].
   No-JS safe: everything readable without this file.
   ========================================================================== */

:root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1d212a;
    --text: #e6e8eb;
    --text-strong: #ffffff;
    --muted: #9aa3ad;
    --border: #2a2f3a;
    --accent: #2dd4a7;
    --accent-strong: #5eead4;
    --accent-contrast: #08120f;
    --link: #2dd4a7;
    --hover: #5eead4;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);

    /* Skill proficiency level colors (dark theme) */
    --familiar-bg: rgba(138, 180, 248, 0.14);
    --familiar-border: rgba(138, 180, 248, 0.5);
    --familiar-text: #8ab4f8;
    --proficient-bg: rgba(255, 209, 102, 0.14);
    --proficient-border: rgba(255, 209, 102, 0.5);
    --proficient-text: #ffd166;
    --advanced-bg: rgba(116, 209, 160, 0.14);
    --advanced-border: rgba(116, 209, 160, 0.5);
    --advanced-text: #74d1a0;
}

[data-theme="light"] {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #1a1d21;
    --text-strong: #000000;
    --muted: #5b6470;
    --border: #dde1e7;
    --accent: #0d9488;
    --accent-strong: #0f766e;
    --accent-contrast: #ffffff;
    --link: #0d9488;
    --hover: #0f766e;
    --shadow: 0 4px 20px rgba(20, 30, 40, 0.08);

    /* Skill proficiency level colors (light theme) */
    --familiar-bg: rgba(10, 88, 202, 0.22);
    --familiar-border: rgba(10, 88, 202, 0.6);
    --familiar-text: #0842a0;
    --proficient-bg: rgba(180, 83, 9, 0.22);
    --proficient-border: rgba(180, 83, 9, 0.6);
    --proficient-text: #9a3f00;
    --advanced-bg: rgba(21, 115, 71, 0.22);
    --advanced-border: rgba(21, 115, 71, 0.6);
    --advanced-text: #0f5c39;
}

/* ---------- Base ---------- */

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
}

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.65;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-strong);
    line-height: 1.25;
    margin: 0 0 0.75rem;
}

h1 { font-size: clamp(2rem, 5vw, 2.9rem); }
h2 { font-size: clamp(1.35rem, 3.5vw, 1.75rem); }
h3 { font-size: 1.1rem; }

p {
    margin: 0 0 1rem;
}

a {
    color: var(--link);
    text-decoration: none;
}

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

strong { color: var(--text-strong); }

img,
iframe {
    max-width: 100%;
}

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

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

/* ---------- Accessibility helpers ---------- */

.visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

.skip-link {
    position: absolute;
    top: -2.5rem;
    left: 1rem;
    z-index: 50;
    background-color: var(--accent);
    color: var(--accent-contrast);
    padding: 0.5rem 1rem;
    border-radius: 0 0 0.5rem 0.5rem;
    text-decoration: none;
    opacity: 0;
    pointer-events: none;
}

.skip-link:focus {
    top: 0;
    color: var(--accent-contrast);
    opacity: 1;
    pointer-events: auto;
}

/* ---------- Header / navigation ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background-color: color-mix(in srgb, var(--bg) 85%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.site-nav {
    max-width: 1040px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}

.brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-strong);
    text-decoration: none;
    margin-right: auto;
}

.brand:hover { color: var(--accent); }

.nav-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

.nav-list a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.35rem 0.1rem;
}

.nav-list a:hover { color: var(--text-strong); }

.nav-list a[aria-current="page"] {
    color: var(--accent);
    box-shadow: inset 0 -2px 0 var(--accent);
}

/* Theme switch — only shown when JS is available */
.theme-switch {
    display: none;
}

.no-js .theme-switch { display: none; }

html.js .theme-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 1.3rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease, border-color 0.2s ease;
}

html.js .theme-switch:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

html.js .theme-switch .theme-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0.2rem;
    width: 0.95rem;
    height: 0.95rem;
    color: var(--text-strong);
    transition: left 0.2s ease;
    pointer-events: none;
}

html.js .theme-switch .theme-icon--sun {
    display: block;
}

html.js .theme-switch .theme-icon--moon {
    display: none;
}

html.js[data-theme="light"] .theme-switch .theme-icon {
    left: calc(100% - 0.2rem - 0.95rem);
}

html.js[data-theme="light"] .theme-switch .theme-icon--sun {
    display: none;
}

html.js[data-theme="light"] .theme-switch .theme-icon--moon {
    display: block;
}

/* Without CSS/JS the button shows its text label; hide icons without JS so the
   fallback is a clean labelled button. */
html.no-js .theme-switch svg {
    display: none;
}

/* ---------- Main layout ---------- */

main {
    max-width: 1040px;
    margin: 0 auto;
    padding: 2.5rem 1.25rem 3rem;
}

.section,
main > .card {
    margin-bottom: 2.5rem;
}

.section > :last-child,
.card > :last-child {
    margin-bottom: 0;
}

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

.hero {
    max-width: 46rem;
    margin: 0 auto 3rem;
    text-align: center;
}

.hero .tagline {
    font-size: clamp(1.1rem, 3vw, 1.35rem);
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.hero .contact {
    margin-top: 1.5rem;
}

.contact a {
    white-space: nowrap;
}

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

.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.9rem;
    padding: clamp(1.25rem, 3vw, 1.75rem);
    box-shadow: var(--shadow);
}

.entry-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.25rem 1rem;
}

.entry-head h3 {
    margin-bottom: 0;
}

.entry-head time {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.entry-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 1rem;
    row-gap: 0.25rem;
    align-items: baseline;
}

.entry-grid h3 {
    margin-bottom: 0;
}

.entry-grid time {
    grid-column: 2;
    justify-self: end;
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.entry-grid .subtitle {
    grid-column: 1;
}

.entry-grid .location {
    grid-column: 2;
    justify-self: end;
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.subtitle {
    color: var(--muted);
    font-style: italic;
    margin-bottom: 0.75rem;
}

.badge {
    display: inline-block;
    background-color: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 999px;
    padding: 0.28rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.tech-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0 0;
}

/* ---------- About ---------- */

.about-card {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.about-card .portrait {
    margin: 0;
    flex: 0 0 auto;
}

.portrait img {
    width: 100%;
    max-width: 250px;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--accent);
}

.about-card > div {
    flex: 1 1 320px;
    min-width: 0;
}

.headline {
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

/* ---------- Alternative: larger card image details ---------- */

.entry-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.entry-list > li {
    padding: 1.1rem 0;
    border-bottom: 1px solid var(--border);
}

.entry-list > li:first-child { padding-top: 0; }
.entry-list > li:last-child { padding-bottom: 0; border-bottom: 0; }

/* ---------- Projects ---------- */

.project h2 {
    margin-bottom: 1rem;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 0.75rem;
    margin: 0 0 1.25rem;
}

.gallery img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 0.6rem;
    border: 1px solid var(--border);
    background-color: var(--surface-2);
}

/* Carousel mode — added by script.js when JS is available */
.gallery.is-carousel {
    display: block;
    position: relative;
}

.gallery.is-carousel img {
    display: none;
    width: auto;
    max-height: min(70vh, 520px);
    aspect-ratio: auto;
    object-fit: contain;
    margin: 0 auto;
}

.gallery.is-carousel img.is-active {
    display: block;
}

.gallery-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.gallery-nav button {
    background-color: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.gallery-nav button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.gallery-nav .gallery-count {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ---------- Project metadata ---------- */

.meta {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1rem;
    row-gap: 0.35rem;
    margin: 0 0 1.25rem;
}

.meta dt {
    font-weight: 600;
    color: var(--muted);
}

.meta dd {
    margin: 0;
}

.links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin: 1.25rem 0 0;
}

.links a,
.btn {
    display: inline-block;
    background-color: var(--accent);
    color: var(--accent-contrast);
    border-radius: 999px;
    padding: 0.4rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.links a:hover,
.btn:hover {
    background-color: var(--accent-strong);
    color: var(--accent-contrast);
    text-decoration: none;
}

.btn {
    border: none;
    cursor: pointer;
}

/* ---------- Scratch embeds ---------- */

.scratch-embed {
    margin: 0 0 1.25rem;
}

.scratch-embed iframe {
    display: block;
    width: min(100%, 485px);
    height: auto;
    aspect-ratio: 485 / 402;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background-color: var(--surface-2);
}

.scratch-embed figcaption {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.scratch-embed figcaption a {
    display: inline-block;
    color: var(--link);
    text-decoration: none;
}

/* ---------- Skills ---------- */

.skill-category {
    box-shadow: var(--shadow);
}

.skill-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.skill-list li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.skill-list li:last-child {
    border-bottom: 0;
}

.skill-name {
    font-weight: 600;
    color: var(--text-strong);
}

.skill-level {
    background-color: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 999px;
    padding: 0.18rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.skill-level--familiar {
    background-color: var(--familiar-bg);
    border-color: var(--familiar-border);
    color: var(--familiar-text);
}

.skill-level--proficient {
    background-color: var(--proficient-bg);
    border-color: var(--proficient-border);
    color: var(--proficient-text);
}

.skill-level--advanced {
    background-color: var(--advanced-bg);
    border-color: var(--advanced-border);
    color: var(--advanced-text);
}

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

.site-footer {
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 2rem 1.25rem;
    color: var(--muted);
}

.site-footer address {
    font-style: normal;
    margin-bottom: 1rem;
}

.site-footer address p:last-child {
    margin-bottom: 0;
}

.site-footer a {
    white-space: nowrap;
}

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

@media (max-width: 620px) {
    .site-nav {
        gap: 0.5rem;
    }

    .brand {
        flex-basis: 100%;
    }

    .hero {
        text-align: left;
    }

    .contact a {
        white-space: normal;
    }

    .about-card {
        justify-content: center;
        text-align: center;
    }

    .entry-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.15rem;
    }

    .entry-grid {
        grid-template-columns: 1fr;
    }

    .entry-grid time,
    .entry-grid .location {
        justify-self: start;
    }

    .meta {
        grid-template-columns: 1fr;
        row-gap: 0.15rem;
    }

    .meta dd {
        margin-bottom: 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* ---------- Print ---------- */

@media print {
    .site-header,
    .theme-switch,
    .skip-link,
    .gallery-nav {
        display: none !important;
    }

    body {
        background: #ffffff;
        color: #000000;
    }

    main {
        max-width: none;
    }
}