:root {
    --bg-color: #FAF9F4;
    --primary-color: #000000;
    --border-width: 1.5px;
    --font-main: 'Anton', sans-serif;
    --font-mono: 'Space Mono', monospace;
    --max-width: 1400px;
    --nav-height: 60px;
}

/* Single source of truth for dark theme — toggled via one class on <html>.
   Everything that reads these variables transitions automatically. */
:root.theme-dark {
    --bg-color: #0f0f0f;
    --primary-color: #FAF9F4;
}

/* ─── Base Reset ─── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* scroll-behavior handled by GSAP ScrollSmoother */
    overflow-x: hidden;
}

/* ─── GSAP ScrollSmoother ─── */
#smooth-wrapper {
    overflow: hidden;
    position: fixed;
    height: 100%;
    width: 100%;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#smooth-content {
    overflow: visible;
    width: 100%;
    padding-top: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
}

body {
    background-color: var(--bg-color);
    color: var(--primary-color);
    font-family: var(--font-mono);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* ─── Global Link Overrides ─── */
/* Prevent mobile browsers from auto-styling phone numbers in purple/blue */
a[href^="tel"],
a[href^="mailto"] {
    color: inherit;
    text-decoration: none;
}

a[href^="tel"]:hover,
a[href^="mailto"]:hover {
    text-decoration: underline;
}

/* ─── Navigation ─── */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: env(safe-area-inset-top, 0px) max(2rem, env(safe-area-inset-right, 2rem)) 0 max(2rem, env(safe-area-inset-left, 2rem));
    height: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    z-index: 1000;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-color); /* fallback: Firefox <113, Safari <15.4 */
    background-color: color-mix(in srgb, var(--bg-color) 75%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: var(--border-width) solid transparent;
    transition: border-color 0.3s, background-color 0.3s;
}

.navbar.scrolled {
    border-bottom-color: var(--primary-color);
}

.nav-left a,
.nav-left span {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 0;
}

.nav-right a {
    text-decoration: none;
    color: var(--primary-color);
    margin-left: 1.5rem;
    position: relative;
    font-size: 0.9rem;
}

.nav-right a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

.nav-right a:hover::after {
    width: 100%;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-family: var(--font-mono);
    font-weight: 700;
    cursor: pointer;
    margin-left: 1rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

.divider {
    margin-left: 1rem;
}

/* ─── Hamburger Button ─── */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    z-index: 1100;
    flex-shrink: 0;
}

.hamburger span {
    display: block;
    height: 2px;
    width: 100%;
    background-color: var(--primary-color);
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center;
}

.hamburger.is-active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger.is-active span:nth-child(2) {
    opacity: 0;
}

.hamburger.is-active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ─── Layout Containers ─── */
.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    width: 100%;
}

/* ─── Hero Card ─── */
.hero-card {
    position: relative;
    width: 90%;
    max-width: var(--max-width);
    min-height: 80vh;
    min-height: 80dvh;
    border: var(--border-width) solid var(--primary-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem;
    margin-bottom: 0;
}

/* ─── Corner Marks ─── */
.corner-mark {
    position: absolute;
    width: 20px;
    height: 20px;
    border: var(--border-width) solid var(--primary-color);
}

.top-left {
    top: -1px;
    left: -1px;
    border-right: none;
    border-bottom: none;
}

.top-right {
    top: -1px;
    right: -1px;
    border-left: none;
    border-bottom: none;
}

.bottom-left {
    bottom: -1px;
    left: -1px;
    border-right: none;
    border-top: none;
}

.bottom-right {
    bottom: -1px;
    right: -1px;
    border-left: none;
    border-top: none;
}

/* ─── Card Header & Footer ─── */
.card-header,
.card-footer {
    display: flex;
    justify-content: space-between;
    font-size: .9rem;
    text-transform: uppercase;
    line-height: 1.4;
    z-index: 2;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.align-right {
    text-align: right;
    letter-spacing: 2.3px;
}

/* ─── Hero Content ─── */
.hero-content-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    width: 100%;
    margin: 2rem 0;
    position: relative;
    z-index: 5;
}

/* ─── Fluid Typography ─── */
.hero-title {
    text-align: left;
    font-family: var(--font-main);
    font-size: clamp(3rem, 10vw, 9rem);
    line-height: 1;
    text-transform: uppercase;
    margin: 0;
    z-index: 1;
    width: 100%;
    word-wrap: break-word;
}

.hero-letter {
    display: inline-block;
    transition: color 0.15s ease;
    cursor: default;
}

.hero-letter.hero-space {
    pointer-events: none;
}

@media (hover: hover) {
    .hero-letter:not(.hero-space):hover {
        color: #46afff;
    }
}

.tiny-code {
    font-size: 0.6rem;
    opacity: 0.7;
    margin-bottom: 1rem;
}

/* ─── Hero Lanyard Panel (right side of hero) ─── */
.hero-lanyard-panel {
    flex: 1;
    min-width: 0;
    /* Responsive: fluid height scales between 360px and 510px based on viewport */
    height: clamp(360px, 40vw, 510px);
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    /* Same variable + same transition as body — transitions in sync.
       Shows through the transparent iframe/canvas with zero timing lag. */
    background-color: var(--bg-color);
    transition: background-color 0.3s ease;
}

.hero-lanyard-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    overflow: hidden;
}



.sticker-float-bottom {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.social-icon {
    width: auto;
    height: 2.5rem;
    vertical-align: middle;
    margin-left: 10px;
}

.social-icon path {
    fill: var(--primary-color);
    transition: fill 0.3s ease;
}

@media (hover: hover) {
    .linkedin-link:hover .social-icon path {
        fill: #0A66C2;
    }

    .github-link:hover .social-icon path {
        fill: #6e5494;
    }
}

/* ─── Marquee ─── */
.marquee-container {
    border-top: var(--border-width) solid var(--primary-color);
    border-bottom: var(--border-width) solid var(--primary-color);
    padding: 0.8rem 0;
    white-space: nowrap;
    overflow: hidden;
    font-weight: 700;
    font-size: 0.9rem;
    background: var(--bg-color);
    width: 100%;
    margin-top: -15px;
    margin-bottom: 0;
}

.marquee-content {
    display: inline-block;
    white-space: nowrap;
    padding-left: 0;
    animation: marquee 30s linear infinite;
    will-change: transform;
}

.marquee-icon {
    height: 22px;
    width: auto;
    margin: 0 16px;
    vertical-align: middle;
}

@keyframes marquee {
    0% {
        transform: translate3d(0, 0, 0);
    }

    100% {
        transform: translate3d(-50%, 0, 0);
    }
}

/* ─── Scroll Button ─── */
.scroll-container {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    text-decoration: none;
    outline: none;
}

.scroll-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: transform 0.3s ease;
}

.scroll-container:hover .scroll-wrapper {
    transform: translateY(-8px);
}

.scroll-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--primary-color);
    transition: opacity 0.3s ease;
}

.scroll-container:hover .scroll-label {
    opacity: 0.7;
}

.mouse-icon {
    width: 30px;
    height: 50px;
    border-radius: 9999px;
    display: flex;
    justify-content: center;
    padding-top: 10px;
    background: transparent;
    border: var(--border-width) solid var(--primary-color);
    transition: all 0.3s ease;
}

.scroll-container:hover .mouse-icon {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.scroll-container:hover .wheel {
    background: var(--bg-color);
}

.wheel {
    width: 6px;
    height: 12px;
    border-radius: 9999px;
    background: var(--primary-color);
    animation: scrollWheel 2s cubic-bezier(0.77, 0, 0.175, 1) infinite;
    transition: 0.3s ease;
}

.bounce-arrow {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
    margin-top: -5px;
    animation: bounceArrow 2s infinite;
}

@keyframes scrollWheel {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(12px);
        opacity: 0;
    }
}

@keyframes bounceArrow {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-5px);
    }

    60% {
        transform: translateY(-3px);
    }
}

/* ─── Content Section (default padding, overridden by media queries) ─── */
#content {
    padding: 4rem 2rem 6rem;
}

/* ─── Certifications Section ─── */
#certifications {
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
    padding: 0 0 4rem 0;
    display: flex;
    flex-direction: column;
}

.section-title {
    font-family: "Trirong", serif;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    text-transform: uppercase;
    margin-bottom: 2rem;
    text-align: left;
    line-height: 1;
    width: 100%;
}



/* ─── 3D Gallery Frames ─── */
.cert-card {
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    height: auto;
    transition: transform 0.3s ease;
}

@media (hover: hover) {
    .cert-card:hover {
        transform: translateY(-5px);
    }
}

.cert-card::before,
.cert-card::after {
    display: none;
}

.cert-img-container {
    width: 100%;
    aspect-ratio: 16/10;
    background: #ffffff;
    border: 9px solid #c2a34f;
    border-style: ridge;
    border-color: #e5c777 #b08d35 #8a6d23 #d6b863;
    padding: 5%;
    position: relative;
    box-shadow: 6px 6px 15px rgba(0, 0, 0, 0.25);
}

.cert-img-container::before {
    content: "";
    position: absolute;
    top: 3.5%;
    left: 3.5%;
    right: 3.5%;
    bottom: 3.5%;
    border: 1px solid rgba(0, 0, 0, 0.4);
    pointer-events: none;
    display: block;
}

.cert-img-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border: 1px solid #eaeaea;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
}

.cert-details {
    padding: 1.5rem 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
}

.cert-details h3 {
    font-family: "Trirong", serif;
    font-size: 1.1rem;
    text-transform: uppercase;
    line-height: 1.1;
    margin: 0;
    color: var(--primary-color);
}

.cert-details p {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    opacity: 0.8;
    margin: 0;
    line-height: 1;
    color: var(--primary-color);
}

.cert-card a,
.cert-card a:visited,
.cert-card a:hover,
.cert-card a:active {
    color: var(--primary-color);
    text-decoration: none;
}

/* ─── Cert Hover Preview ─── */
.cert-preview-overlay {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    /* Responsive: cap at 500px but never exceed 90% viewport width */
    width: min(500px, 90vw);
    background: var(--bg-color);
    border: var(--border-width) solid var(--primary-color);
    padding: 0.5rem;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cert-preview-overlay img {
    width: 100%;
    height: auto;
    aspect-ratio: 16/10;
    object-fit: contain;
    background: #ffffff;
    border: var(--border-width) solid var(--primary-color);
    display: block;
}

/* Responsive: only show cert preview on devices that support hover */
@media (hover: hover) {
    .cert-card:hover .cert-preview-overlay {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(-15px);
    }
}

/* ─── React Component Styles ─── */
.react-header {
    margin-bottom: 3rem;
    border-bottom: var(--border-width) solid var(--primary-color);
    padding-bottom: 1.5rem;
}

.react-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.react-tab-btn {
    background: var(--bg-color);
    border: var(--border-width) solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.6rem 1.2rem;
    font-family: var(--font-mono);
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    white-space: nowrap;
}

.react-tab-btn:hover {
    background: rgba(125, 125, 125, 0.1);
}

.react-tab-btn.active {
    background: var(--primary-color);
    color: var(--bg-color);
    box-shadow: 5px 5px 0px var(--primary-color);
    transform: translateY(-3px);
}

/* ─── Grid Layouts ─── */
.react-grid-certs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.react-grid-badges {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    justify-items: center;
    gap: 3rem;
}

/* ─── Badge Cards ─── */
.badge-card {
    border: var(--border-width) solid var(--primary-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
    transition: all 0.3s ease;
}

@media (hover: hover) {
    .badge-card:hover {
        background: var(--primary-color);
        color: var(--bg-color);
        transform: scale(1.05);
    }
}

/* ─── Nav Active Link ─── */
.active-link {
    border-bottom: 2px solid var(--primary-color);
}

/* ─── Fade In ─── */
.fade-in {
    animation: fadeIn 0.4s ease-in forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   Mobile-first approach with breakpoints:
   480px (large phone) → 768px (tablet) →
   1024px (laptop) → 1440px (desktop) → 1600px+ (ultrawide)
════════════════════════════════════════════ */

/* ── Large Desktop (1024px+) ── */
@media (min-width: 1024px) {
    .hero-content-wrapper {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .hero-title {
        width: 60%;
        font-size: clamp(4rem, 5.5vw, 9rem);
    }
}

/* ── Desktop (1440px+) ── */
@media (min-width: 1440px) {
    /* Responsive: optimise layout for standard desktop monitors */
    .hero-title {
        font-size: clamp(5rem, 5.5vw, 9rem);
    }

    .container {
        padding: 2.5rem;
    }

    .react-grid-certs {
        grid-template-columns: repeat(3, 1fr);
    }


}

/* ── Tablet (768px – 1023px) ── */
@media (max-width: 1023px) and (min-width: 768px) {
    .hero-card {
        min-height: 70vh;
        padding: 1.75rem;
    }

    .hero-title {
        font-size: clamp(3.5rem, 8vw, 6rem);
    }

    .container {
        padding: 1.5rem;
    }

    /* Responsive: cert preview adapts to tablet width */
    .cert-preview-overlay {
        width: min(380px, 85vw);
    }

    /* Responsive: lanyard scales down on tablets */
    .hero-lanyard-panel {
        height: clamp(260px, 35vw, 340px);
    }

    /* Responsive: cert grid two columns at tablet */
    .react-grid-certs {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.75rem;
    }

    /* Responsive: scroll button repositioned for shorter hero */
    .scroll-container {
        bottom: 24px;
    }

    /* Responsive: content section padding for tablet */
    #content {
        padding: 3rem 1.5rem 5rem !important;
    }
}

/* ── Mobile (< 768px) ── */
@media (max-width: 767px) {

    /* Remove backdrop-filter on mobile — it creates a containing block that breaks
       position:fixed on child elements (nav-right panel) in iOS Safari */
    .navbar {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background-color: var(--bg-color);
    }

    /* Hamburger visible, nav links hidden by default */
    .hamburger {
        display: flex;
    }

    /* Slide-in panel from the right */
    .nav-right {
        display: flex;
        position: fixed;
        top: calc(var(--nav-height) + env(safe-area-inset-top, 0px));
        right: 0;
        height: auto;
        width: min(160px, 40vw);
        background-color: color-mix(in srgb, var(--bg-color) 80%, transparent);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-radius: 18px 0 0 18px;
        flex-direction: column;
        align-items: flex-end;
        padding: 1.5rem 1.5rem 2rem;
        gap: 1.25rem;
        z-index: 999;
        transform: translateX(100%);
        visibility: hidden;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0s linear 0.3s;
        box-shadow: -8px 8px 40px rgba(0, 0, 0, 0.18), -2px 2px 12px rgba(0, 0, 0, 0.1);
    }

    .nav-right.nav-open {
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                    visibility 0s linear 0s;
    }

    /* Responsive: larger tap targets for mobile nav links */
    .nav-right a {
        margin-left: 0;
        font-size: 1rem;
        padding: 0.4rem 0;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        width: 100%;
        text-align: right;
    }

    .nav-right .divider {
        display: none;
    }

    /* Responsive: bigger tap targets for nav buttons */
    .nav-btn {
        margin-left: 0;
        padding: 0.4rem 0;
        font-size: 0.9rem;
        min-height: 44px;
        width: 100%;
        text-align: right;
    }

    /* Hero */
    .hero-card {
        width: 95%;
        padding: 1.25rem;
        min-height: auto;
    }

    .hero-title {
        font-size: clamp(2.5rem, 13vw, 5rem);
    }

    /* Lanyard on mobile: stack below title, responsive height */
    .hero-lanyard-panel {
        width: 100%;
        /* Responsive: fluid height instead of fixed 420px */
        height: clamp(300px, 55vw, 420px);
        flex: none;
    }

    .card-header {
        font-size: 0.75rem;
    }

    .card-footer {
        flex-direction: column;
        gap: 1.5rem;
    }

    .sticker-float-bottom {
        justify-content: flex-start;
    }

    .align-right {
        text-align: left;
        margin-top: 4px;
    }

    .scroll-container {
        position: relative;
        bottom: auto;
        left: auto;
        transform: none;
        margin: 1rem auto 0;
        display: block;
        width: fit-content;
    }

    /* Container padding */
    .container {
        padding: 1rem;
    }

    /* Content section */
    #content {
        padding: 3rem 1rem 4rem !important;
    }

    /* Marquee */
    .marquee-icon {
        height: 14px;
        margin: 0 8px;
    }

    /* Responsive: marquee font scales down on mobile */
    .marquee-container {
        font-size: 0.7rem;
        padding: 0.5rem 0;
    }

    /* Cert grid */
    .react-grid-certs {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .react-grid-badges {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        justify-items: center;
        gap: 2rem;
    }

    /* Cert preview: hide on touch devices (no hover) */
    .cert-preview-overlay {
        display: none;
    }

    /* Credentials tabs */
    .react-tabs {
        gap: 0.5rem;
    }

    .react-tab-btn {
        padding: 0.5rem 0.9rem;
        font-size: 0.78rem;
    }

    /* Responsive: social icons slightly smaller for mobile */
    .social-icon {
        height: 2rem;
    }
}

/* ── Large phones / Small tablets (481px – 767px) ── */
@media (min-width: 481px) and (max-width: 767px) {
    /* Responsive: two-column cert grid on larger phones */
    .react-grid-certs {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }

    .hero-card {
        width: 92%;
    }

    /* Responsive: slightly more breathing room */
    .container {
        padding: 1.25rem;
    }

    #content {
        padding: 3rem 1.25rem 4rem !important;
    }
}

/* ── Small phones (< 480px) ── */
@media (max-width: 480px) {
    .hero-title {
        font-size: clamp(2rem, 15vw, 3.5rem);
    }

    .hero-card {
        width: 98%;
        padding: 1rem;
    }

    /* Hide lanyard on tiny phones to avoid cramping */
    .hero-lanyard-panel {
        display: none;
    }

    .navbar {
        padding: 0 1rem;
    }

    /* Responsive: cert preview not useful on small phones */
    .cert-preview-overlay {
        display: none;
    }

    /* Responsive: card header font scales for tiny screens */
    .card-header {
        font-size: 0.65rem;
    }

    /* Responsive: section title scales down */
    .section-title {
        font-size: clamp(1.4rem, 6vw, 2rem);
    }

    /* Responsive: badges grid tighter on tiny phones */
    .react-grid-badges {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        justify-items: center;
        gap: 1.5rem;
    }

    /* Responsive: tab buttons wrap nicely */
    .react-tab-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.72rem;
    }

    /* Marquee even smaller on tiny phones */
    .marquee-container {
        font-size: 0.62rem;
        padding: 0.4rem 0;
    }

    .marquee-icon {
        height: 12px;
        margin: 0 6px;
    }
}

/* ── Wide/Ultrawide screens (> 1600px) ── */
@media (min-width: 1600px) {
    .hero-title {
        font-size: clamp(6rem, 6vw, 10rem);
    }

    /* Responsive: wider max-width for ultrawide monitors */
    .container {
        padding: 3rem;
    }
}

/* ─── Back to Top Button ─── */
#back-to-top {
    position: fixed;
    bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    right: calc(2rem + env(safe-area-inset-right, 0px));
    z-index: 9000;
    width: 44px;
    height: 44px;
    background: var(--bg-color);
    color: var(--primary-color);
    border: var(--border-width) solid var(--primary-color);
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease,
                background-color 0.25s ease, color 0.25s ease;
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#back-to-top:hover {
    background: var(--primary-color);
    color: var(--bg-color);
}

@media (max-width: 767px) {
    #back-to-top {
        bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
        right: calc(1.25rem + env(safe-area-inset-right, 0px));
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* ─── Skip to Main Content (keyboard navigation) ─── */
.skip-link {
    position: absolute;
    top: -60px;
    left: max(1rem, env(safe-area-inset-left, 1rem));
    background: var(--primary-color);
    color: var(--bg-color);
    padding: 0.5rem 1rem;
    z-index: 10000;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    border: var(--border-width) solid var(--bg-color);
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: calc(env(safe-area-inset-top, 0px) + 4px);
}

/* ─── Focus Visible (keyboard navigation) ─── */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

/* Remove default focus ring for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}