/* ===========================================
   CSS CUSTOM PROPERTIES (VARIABLES)
   =========================================== */

/* Dark theme (default) */
:root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #21262d;
    --card-bg: #161b22;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #a7b2bd;
    
    --accent-purple: #c792ea;
    --accent-blue: #82aaff;
    --accent-pink: #f07178;
    --accent: var(--accent-blue);
    
    --border: #222a33;
    --border-subtle: #1a1f26;
    --border-card: #222832;
    --border-card-hover: #2b3340;
    --border-button: #30363d;
    
    --focus-ring: #82aaff;
    --nav-active: #e6ecf3;
    
    --bg-primary: rgba(13, 17, 23, .82);
    --bg-secondary: #0b0f14;
    
    --toggle-track-bg: rgba(255, 255, 255, .08);
    --toggle-track-border: #2c333d;
    --toggle-thumb-bg: #e6eef6;
    --toggle-thumb-shadow: rgba(0, 0, 0, .3);
    
    --badge-bg: #0f141a;
    --badge-text: #95a0ab;
    --badge-border: #2c323b;
    
    --linkedin-square-dark: #0b2a4a;
    --linkedin-square-light: #e6eef6;
    --linkedin-square-bg: var(--linkedin-square-dark);
    --linkedin-glyph-fill: #ffffff;
    
    --spacing: 1rem;
    --max-width: 980px;
    --media-h: 240px;
    --device-frame-h: 320px;
    --card-pad-x: 1rem;
    --card-pad-y: 1rem;
}

/* Light theme media query */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #f4f6fb;
        --surface: #ffffff;
        --surface-2: #f8f9fc;
        --card-bg: #ffffff;
        --text-primary: #151d27;
        --text-secondary: #4f5a69;
        --text-muted: #4f5a69;
        
        --accent-purple: #5b3db8;
        --accent-blue: #2f58c8;
        --accent-pink: #b13448;
        --accent: var(--accent-blue);
        
        --border: #dde3ec;
        --border-subtle: #eceff5;
        --focus-ring: #365088;
        --nav-active: #1b2330;
        
        --bg-primary: rgba(244, 246, 251, .9);
        --bg-secondary: #ffffff;
    }
}

/* Explicit light theme override */
[data-theme="light"] {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --card-bg: #ffffff;
    --text-primary: #151d27;
    --text-secondary: #4f5a69;
    --text-muted: #4f5a69;
    
        --accent-purple: #5b3db8;
        --accent-blue: #2f58c8;
    --accent-pink: #b13448;
    --accent: var(--accent-blue);
    
    --border: #dde3ec;
    --border-subtle: #eceff5;
    --border-card: #dde3ec;
    --border-card-hover: #b9c2d0;
    --border-button: #cdd5e2;
    
    --focus-ring: #365088;
    --nav-active: #1b2330;
    
    --bg-primary: rgba(244, 246, 251, .92);
    --bg-secondary: #ffffff;
    
    --toggle-track-bg: rgba(0, 0, 0, .06);
    --toggle-track-border: #cad3de;
    --toggle-thumb-bg: #2e3b4a;
    --toggle-thumb-shadow: rgba(0, 0, 0, .3);
    
    --badge-bg: #f0f3f7;
    --badge-text: #4d5b68;
    --badge-border: #cad3de;
    
    --linkedin-square-bg: var(--linkedin-square-light);
    --linkedin-glyph-fill: var(--accent-blue);
    
    --device-frame-h: 320px;
}

/* Explicit dark theme override */
[data-theme="dark"] {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #21262d;
    --card-bg: #161b22;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    
    --accent-purple: #c792ea;
    --accent-blue: #82aaff;
    --accent-pink: #f07178;
    
    --border: #222a33;
    --border-subtle: #1a1f26;
    --focus-ring: #82aaff;
    
    --linkedin-square-bg: var(--linkedin-square-dark);
    --linkedin-glyph-fill: #ffffff;
}


/* ===========================================
   BASE STYLES
   =========================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans JP', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    font-optical-sizing: auto;
    text-rendering: optimizeLegibility;
}

h1,
h2,
h3 {
    font-family: 'Raleway', 'Noto Sans JP', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

h2,
h3 {
    text-wrap: balance;
}

p {
    text-wrap: pretty;
    margin-bottom: 1rem;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    text-underline-offset: .18em;
    text-decoration-thickness: .08em;
}

a:hover {
    text-decoration: none;
}

.btn:focus-visible,
a:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.container {
    width: 90%;
    max-width: var(--max-width);
    margin: 0 auto;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 8px;
    background: var(--surface);
    color: var(--text-primary);
    padding: 8px 12px;
    border: 2px solid var(--accent-blue);
    z-index: 1000;
}

.skip-link:focus {
    left: 10px;
}

.visually-hidden {
    position: absolute !important;
    left: -9999px !important;
    top: 0 !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}


/* ===========================================
   NAVIGATION
   =========================================== */

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: var(--spacing) 0;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 100;
    flex-wrap: wrap;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 90%;
    max-width: var(--max-width);
    margin: 0 auto;
    flex-wrap: wrap;
}

.logo {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--accent-purple);
    margin: 0 .75rem 0 0;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 1.25rem;
    margin-left: .75rem;
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color .2s ease;
    padding: .2rem .35rem;
    border-radius: .4rem;
    line-height: 1.1;
}

.nav-links a:hover {
    color: inherit;
}

.nav-links a[aria-current="page"] {
    color: var(--nav-active);
}

.nav-links a[aria-current="page"]::after {
    content: "";
    display: block;
    width: 100%;
    height: 2px;
    margin-top: 4px;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-blue));
    border-radius: 2px;
}


/* ===========================================
   THEME TOGGLE
   =========================================== */

.theme-toggle {
    margin-left: auto;
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 32px;
    width: 52px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    vertical-align: middle;
}

.theme-toggle .switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--toggle-track-bg);
    border: 1px solid var(--toggle-track-border);
    transition: background .2s ease, border-color .2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
}

.theme-toggle .switch-thumb {
    position: absolute;
    left: 3px;
    top: 50%;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--toggle-thumb-bg);
    box-shadow: 0 1px 2px var(--toggle-thumb-shadow);
    transition: transform .2s ease;
    z-index: 1;
    transform: translate(0, -50%);
}

.theme-toggle[aria-checked="true"] .switch-thumb {
    transform: translate(24px, -50%);
}

.theme-toggle .toggle-sun {
    color: #f59e0b;
    opacity: 1;
    transition: opacity .2s ease;
}

.theme-toggle .toggle-moon {
    color: #6366f1;
    opacity: 0.4;
    transition: opacity .2s ease;
}

.theme-toggle[aria-checked="true"] .toggle-sun {
    opacity: 0.4;
}

.theme-toggle[aria-checked="true"] .toggle-moon {
    opacity: 1;
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 3px;
    border-radius: 8px;
}

.theme-toggle .switch-label {
    position: static;
    margin-left: 62px;
    font-size: .85rem;
    color: var(--text-secondary);
}

.theme-toggle .switch-mode {
    margin-left: 62px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
}


/* ===========================================
   HEADER & HERO
   =========================================== */

header {
    position: static;
    background: none;
    border-bottom: 1px solid var(--border-subtle);
}

.hero-wrap {
    background: linear-gradient(rgba(13, 17, 23, .92), rgba(13, 17, 23, .92));
}

[data-theme="light"] .hero-wrap {
    background: linear-gradient(rgba(247, 249, 252, .92), rgba(247, 249, 252, .92));
}

.hero {
    padding-top: 2.75rem;
    padding-bottom: 1.25rem;
    text-align: left;
    background-color: var(--bg-primary);
    border-radius: 16px;
}

[data-theme="light"] .hero {
    background: #f9fafc;
}

.hero .identity {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 1rem;
}

.hero .avatar {
    width: 132px;
    height: 132px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--border-button);
}

.intro h1 {
    margin: 0;
}

.hero h1 {
    font-size: 2.45rem;
    line-height: 1.15;
    letter-spacing: .005em;
    font-weight: 700;
    margin-bottom: .6rem;
    color: var(--accent-purple);
}

.hero .subtitle {
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--text-muted);
    max-width: 40rem;
}

.cta {
    margin-top: 1rem;
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
}

.brand-lockup {
    margin-top: 1.2rem;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: .45rem;
    color: var(--text-muted);
}

.brand-lockup svg {
    width: 180px;
    max-width: 60vw;
    height: auto;
}

.brand-lockup figcaption {
    font-size: .9rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.brand-lockup--card {
    margin-top: 0;
    width: 100%;
    height: 100%;
    padding: 1.5rem 1.25rem;
    justify-content: center;
}

.project-media .brand-lockup svg {
    width: min(260px, 80%);
}


/* ===========================================
   SECTIONS & HEADINGS
   =========================================== */

main > .portfolio:first-of-type {
    padding-top: 1.1rem;
}

h2 {
    font-size: 1.9rem;
    font-weight: 700;
    margin-bottom: .85rem;
    color: var(--accent-purple);
    line-height: 1.18;
    letter-spacing: .003em;
}

h3 {
    font-size: 1.28rem;
    font-weight: 700;
    margin-bottom: .45rem;
    line-height: 1.24;
    letter-spacing: .002em;
}

section[id] {
    scroll-margin-top: 80px;
}

section + section {
    border-top: none;
    padding-top: 1rem;
}

/* ===========================================
   ROLE HEADERS & LAYOUT
   =========================================== */

h3.role-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .5rem;
    margin-bottom: .55rem;
}

.role-header .role-title {
    font-weight: 700;
    flex: 1 1 auto;
    min-width: 12ch;
}

.role-header .role-dates {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-muted);
    flex: 0 0 auto;
    white-space: nowrap;
    letter-spacing: .2px;
}

.role-header .role-affiliation {
    font-size: .85rem;
    font-style: italic;
    color: var(--text-muted);
    flex: 0 0 auto;
    white-space: nowrap;
}

h4.role-subheader {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .5rem;
    font-size: 1.05rem;
    font-weight: 650;
    margin: .1rem 0 .35rem;
    color: var(--accent-blue);
    line-height: 1.3;
}

.role-subheader .role-title {
    font-weight: 650;
    flex: 1 1 auto;
    min-width: 10ch;
}

.role-subheader .role-dates {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    flex: 0 0 auto;
    white-space: nowrap;
    letter-spacing: .3px;
}

.multi-role .role-segments {
    display: flex;
    flex-direction: column;
    gap: .85rem;
    margin-top: .2rem;
}

.multi-role .role-segment {
    position: relative;
    padding: .4rem .2rem .3rem;
}

.multi-role .role-segment + .role-segment {
    padding-top: .75rem;
    margin-top: .2rem;
}


/* ===========================================
   ABOUT SECTION
   =========================================== */

.about {
    margin-top: 0;
    margin-bottom: 2.75rem;
}

section + .about {
    padding-top: 1rem;
}

.about p {
    max-width: 62ch;
    color: var(--text-secondary);
    line-height: 1.55;
}

.about h2 {
    position: relative;
}

.about-terminal {
    margin-top: 4rem;
    margin-bottom: 0;
    padding: 3.25rem 0 2.25rem;
    border-top: 1px solid var(--border-subtle);
}

.about-terminal-inner {
    max-width: 820px;
    margin: 0 auto;
    padding: 0 1.25rem;
    text-align: center;
}

.about-terminal-heading {
    margin: 0 0 .85rem;
    font-size: 1.85rem;
    line-height: 1.1;
    letter-spacing: -.5px;
}

.about-terminal-lead {
    margin: 0 auto;
    font-size: 1.08rem;
    line-height: 1.58;
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 62ch;
    text-align: left;
}


/* ===========================================
   PROJECT CARDS
   =========================================== */

.projects {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.6rem;
    margin-top: 1.25rem;
}

.project-card {
    background-color: var(--card-bg);
    border-radius: .6rem;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
    transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-card);
    position: relative;
}

.project-card:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 3px;
}

.project-card.project-split {
    display: grid;
    grid-template-columns: 1fr min(max(380px, 40%), 420px);
    align-items: stretch;
    column-gap: 1rem;
    grid-template-areas:
        "content media"
        "actions media";
}

.project-card.project-split .project-content {
    grid-column: 1;
    grid-area: content;
    padding: calc(var(--card-pad-y)*0.9) calc(var(--card-pad-x)*0.95);
    max-width: unset;
    margin: 0;
    align-self: start;
    grid-row: 1;
}

.project-card.project-split > .project-media {
    grid-column: 2;
    grid-area: media;
}

.project-card.project-split .project-actions {
    grid-column: 1;
    grid-area: actions;
    align-self: end;
    justify-self: start;
    padding: 0 var(--card-pad-x) var(--card-pad-y);
    margin-top: .5rem;
}

.project-content {
    padding: calc(var(--card-pad-y)*0.9) calc(var(--card-pad-x)*0.95);
    max-width: 70ch;
    margin: 0 auto;
}

.project-content h3 {
    margin-top: .1rem;
    margin-bottom: .5rem;
    font-size: 1.28rem;
    color: var(--accent-blue);
}

.project-content p {
    color: var(--text-secondary);
    font-size: .94rem;
    line-height: 1.5;
    overflow-wrap: break-word;
    hyphens: auto;
    text-wrap: pretty;
}

.project-content > div > strong {
    display: block;
    margin: .5rem 0 .25rem;
    color: var(--text-primary);
}

.project-content ul {
    list-style: none;
    margin: .35rem 0 .9rem;
    padding: 0;
}

.project-content ul > li {
    position: relative;
    margin: .35rem 0;
    padding-left: 1rem;
    color: var(--text-secondary);
}

.project-content ul > li::before {
    content: "";
    position: absolute;
    left: 0;
    top: .6em;
    width: .42rem;
    height: .42rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    opacity: .7;
}

.project-actions {
    padding: 0 var(--card-pad-x) var(--card-pad-y);
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .25rem;
}

.project-card .project-actions {
    align-items: center;
}

.project-card .project-actions .btn {
    margin-top: .25rem;
}

.project-card picture,
.project-card img,
.project-card video,
.project-card svg {
    max-width: 100%;
    height: auto;
}

.project-card.project-split > .project-media,
.project-card .project-content,
.project-card .project-actions {
    overflow-wrap: anywhere;
    word-break: normal;
}


/* ===========================================
   MEDIA & DEVICES
   =========================================== */

.project-card.project-split > .project-media {
    justify-self: center;
    align-self: center;
    margin: 0.5rem var(--card-pad-x) 0.75rem;
    padding: 0 1rem;
    transform: none;
    width: 100%;
}

/* Remove problematic video margin reset that was affecting vertical spacing */
.project-media video {
    padding: 0;
    /* Removed: margin: 0; - This was causing inconsistent vertical spacing */
}

/* Reduce container padding for Petfinder to account for natural video centering */
.petfinder .project-media {
    padding: 0 !important;
}

/* Increase padding for CaringBridge chart for better visual separation */
#caringbridge-card .project-media {
    padding: 0 1.5rem;
}

.project-card > picture > img {
    width: 100%;
    height: var(--media-h);
    object-fit: cover;
    border-radius: .4rem;
}

.project-card > picture > source + img.media-contain {
    object-fit: contain;
}

/* Baseline responsive image rules for all project media */
.project-media img {
    width: 100%;
    height: auto;
    max-width: 100%;
}

.project-card img.media-contain {
    object-fit: contain;
    background: var(--card-bg);
    width: 100%;
    height: auto;
}

.device-tablet {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
}

.device-tablet .device-body {
    position: relative;
    width: 85%;
    height: auto;
    max-width: 85%;
    aspect-ratio: 16/9;
    border: 2px solid var(--border-button);
    border-radius: 16px;
    background: #0b0f14;
    box-shadow: inset 0 0 0 3px #0b0f14, 0 6px 16px rgba(0, 0, 0, .35);
    contain: layout size;
}

.project-card.petfinder .device-tablet .device-body {
    position: relative;
    box-shadow: 0 3px 6px rgba(0, 0, 0, .28), 0 10px 18px -6px rgba(0, 0, 0, .32), 0 26px 42px -18px rgba(0, 0, 0, .45);
    border: 0;
}

.device-tablet .device-screen {
    position: absolute;
    inset: 8px;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
}

.device-tablet .device-screen picture,
.device-tablet .device-screen img,
.device-tablet .device-screen video {
    display: block;
    width: 100%;
    height: 100%;
}

.device-tablet .device-screen img,
.device-tablet .device-screen video {
    object-fit: cover;
    background: #000;
}

.project-card.petfinder {
    --device-frame-h: var(--media-h);
}


/* ===========================================
   BUTTONS
   =========================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .75rem 1.25rem;
    border-radius: .75rem;
    font-weight: 700;
    letter-spacing: .4px;
    font-size: .9rem;
    line-height: 1;
    gap: .5rem;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transform: translateY(0);
    will-change: transform, box-shadow;
    backface-visibility: hidden;
    transition: transform .12s ease, box-shadow .16s ease, background-color .12s ease, border-color .12s ease;
}

.btn svg {
    flex: 0 0 auto;
    display: inline-block;
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}

.btn:hover::before {
    opacity: 0;
}

.btn:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(139, 92, 246, .15);
}

.btn.secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-button);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.btn.secondary::before {
    background: linear-gradient(135deg, rgba(139, 92, 246, .08) 0%, rgba(6, 182, 212, .08) 100%);
}

.btn.secondary:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(139, 92, 246, .12);
}

.btn.small {
    padding: .5rem .75rem;
    border-radius: .6rem;
    font-size: .82rem;
}

[data-theme="light"] .btn:hover {
    background: rgba(0, 0, 0, .04);
    border-color: #94a3b8;
}

[data-theme="light"] .btn.secondary {
    background: rgba(0, 0, 0, .015);
    border-color: #d7dee8;
}

[data-theme="light"] .btn.secondary:hover {
    background: rgba(0, 0, 0, .03);
    border-color: #b9c2d0;
}


/* ===========================================
   SOCIAL & FOOTER
   =========================================== */

.social {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
}

.footer {
    padding: 2rem 0;
    border-top: 1px solid var(--border-subtle);
    background-color: var(--surface);
    text-align: center;
    color: var(--text-secondary);
    font-size: .85rem;
}

.footer .social {
    display: flex;
    gap: .5rem;
    justify-content: center;
    margin: .5rem 0 0;
}


/* ===========================================
   LINKEDIN BADGES
   =========================================== */

.linkedin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex: 0 0 auto;
}

.linkedin-badge svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ===========================================
   RESPONSIVE DESIGN
   =========================================== */

/* Small mobile theme toggle adjustments */
@media (max-width: 560px) {
    .theme-toggle .switch-label {
        display: none;
    }

    .theme-toggle .switch-mode {
        margin-left: 54px;
        font-size: .8rem;
    }

    .theme-toggle {
        width: 48px;
        height: 28px;
    }

    .theme-toggle .switch-thumb {
        width: 20px;
        height: 20px;
        left: 2px;
        top: 50%;
        transform: translate(0, -50%);
    }

    .theme-toggle[aria-checked="true"] .switch-thumb {
        transform: translate(20px, -50%);
    }

    .theme-toggle .switch-track {
        padding: 0 4px;
    }

    .theme-toggle .toggle-sun,
    .theme-toggle .toggle-moon {
        width: 10px;
        height: 10px;
    }
}

@media (max-width: 480px) {
    .theme-toggle .switch-mode {
        margin-left: 52px;
        font-size: .78rem;
    }
}

@media (max-width: 400px) {
    .theme-toggle .switch-mode {
        display: none;
    }
}

/* Navigation responsive behavior */
@media (max-width: 640px) {
    .logo {
        font-size: 1.05rem;
    }

    .nav {
        gap: .5rem;
        flex-wrap: wrap;
    }

    .nav-links {
        width: 100%;
        order: 3;
        gap: .75rem;
        margin: .25rem 0 0 0;
        justify-content: flex-start;
    }

    .nav-links a {
        font-size: .95rem;
    }

    .theme-toggle {
        order: 2;
    }
}

@media (max-width: 380px) {
    .nav {
        gap: .4rem;
    }

    .nav-links {
        gap: .6rem;
    }

    .logo {
        font-size: 1rem;
    }
}

/* Role headers responsive */
@media (min-width: 680px) {
    h3.role-header {
        gap: .75rem;
    }

    .role-header .role-dates {
        margin-left: auto;
        text-align: right;
    }

    h4.role-subheader {
        gap: .65rem;
    }

    .role-subheader .role-dates {
        margin-left: auto;
    }
}

@media (max-width: 479px) {
    h3.role-header {
        flex-direction: column;
        align-items: flex-start;
        gap: .25rem;
    }

    .role-header .role-dates {
        font-size: .85rem;
    }

    h4.role-subheader {
        flex-direction: column;
        align-items: flex-start;
        gap: .25rem;
    }

    .role-subheader .role-dates {
        font-size: .75rem;
    }
}

/* Project spacing improvements */
@media (min-width: 900px) {
    main > .portfolio:first-of-type {
        padding-top: 1.5rem;
    }
}

@media (min-width: 940px) {
    .about-terminal-lead {
        font-size: 1.12rem;
    }
}

/* Desktop layout refinements */
@media (min-width: 900px) {
    .project-card.project-split .project-content {
        padding: calc(var(--card-pad-y)*0.9) calc(var(--card-pad-x)*0.95);
    }
}

@media (min-width: 1040px) {
    h2 {
        margin-bottom: .75rem;
    }

    .project-content h3 {
        margin-bottom: .4rem;
    }

    .project-card.project-split .project-actions {
        padding-bottom: calc(var(--card-pad-y) * 0.85);
    }

    .project-content p {
        margin-bottom: .5rem;
    }

    .project-content .outcome-list li {
        margin: .28rem 0;
    }
}

/* Mid-width tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .project-card.project-split {
        --media-h: clamp(240px, 170px + 8vw, 280px);
    }

    .project-card.petfinder {
        --device-frame-h: clamp(260px, 180px + 10vw, 320px);
    }
}

/* Single column layout - tablets and below */
@media (max-width: 1024px) {
    .projects {
        gap: 1rem;
        grid-template-columns: 1fr;
    }

    .project-card.project-split {
        grid-template-columns: 1fr;
        grid-template-areas:
            "content"
            "media"
            "actions";
    }

    .project-card.project-split .project-content {
        grid-column: 1;
        grid-area: content;
    }

    .project-card.project-split .project-actions {
        grid-column: 1;
        grid-area: actions;
        margin-top: 1.5rem;
        margin-bottom: 1.5rem;
        padding-top: 0;
        padding-bottom: 0;
    }

    .project-card.project-split > .project-media {
        grid-column: 1;
        grid-area: media;
    }

    /* Unified media sizing for single column */
    .project-card.project-split > .project-media {
        width: min(520px, 100%);
        margin-left: auto;
        margin-right: auto;
        margin-top: 1.5rem;
        margin-bottom: 1.5rem;
        justify-self: center;
        align-self: center;
    }

    /* Consistent spacing for Petfinder tablet - match other cards */
    .project-card.petfinder .project-media {
        margin-top: 2rem; /* increased to visually match other media objects */
        margin-bottom: 2rem;
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.25rem;
    }

    .hero .subtitle {
        font-size: 1rem;
    }

    .hero .avatar {
        width: 112px;
        height: 112px;
    }

    .nav-links {
        gap: 1rem;
    }

    .project-content {
        padding: calc(var(--card-pad-y) * 0.9) calc(var(--card-pad-x) * 0.9);
    }

    .project-content h3 {
        font-size: 1.16rem;
    }

    .project-content p {
        margin-bottom: .6rem;
    }

    /* Mobile media adjustments */
    :root,
    [data-theme="light"],
    [data-theme="dark"] {
        --media-h: 220px;
    }

    .device-tablet .device-body {
        width: 85%;
        max-width: 85%;
    }

    /* Consistent vertical spacing for Petfinder tablet on mobile */
    .project-card.petfinder .project-media {
        margin-top: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .project-card.petfinder > .project-media {
        overflow: visible;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.9rem;
    }

    .hero .subtitle {
        font-size: .95rem;
    }

    .hero .avatar {
        width: 96px;
        height: 96px;
    }

    .hero .identity {
        gap: .75rem;
    }

    :root,
    [data-theme="light"],
    [data-theme="dark"] {
        --media-h: 200px;
        --card-pad-x: .85rem;
        --card-pad-y: .85rem;
    }

    .project-content {
        max-width: unset;
    }

    .project-content h3 {
        font-size: 1.08rem;
    }

    .device-tablet {
        height: calc(var(--device-frame-h) * 0.7);
    }

    /* Ensure Petfinder media object keeps consistent vertical spacing on small mobile */
    .project-card.petfinder .project-media {
    /* Match (and slightly exceed) other media objects to compensate for device shadow */
    margin-top: 2rem;
    margin-bottom: 2rem;
    }
}

/* Ultra-small phones */
@media (max-width: 380px) {
    :root,
    [data-theme="light"],
    [data-theme="dark"] {
        --media-h: 184px;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .hero .subtitle {
        font-size: .9rem;
    }

    .hero .avatar {
        width: 88px;
        height: 88px;
    }

    .project-content {
        padding: .7rem .8rem;
    }
}

/* Desktop media sizing */
@media (min-width: 769px) {
    .project-card.project-split > .project-media,
    .project-card.project-split > .project-media {
        margin: 0.5rem calc(var(--card-pad-x) + 4px) 0.85rem;
    }
}


/* ===========================================
   UTILITIES & ACCESSIBILITY
   =========================================== */

/* Scroll anchor offsets for sticky headers */
section[id] {
    scroll-margin-top: 80px;
}

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

    .project-card,
    .project-card img,
    .nav-links a,
    .theme-toggle .switch-track,
    .theme-toggle .switch-thumb,
    .btn {
        transition: none;
    }

    .btn {
        transform: none;
    }

    .btn:hover {
        transform: none;
    }
}
