/* Tokens moved to tokens.css */


/* ─── Base Overrides (device page only) ───────────────────────────────── */
body.device-page {
    --sidebar-width: 260px;
    background-color: var(--md-surface);
    color: var(--md-on-surface);
    font-family: 'Inter', 'Outfit', sans-serif;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body.device-page ::selection {
    background: var(--md-selection-bg);
}


/* ─── Header Overrides ────────────────────────────────────────────────── */
body.device-page header, body.compare-page header {
    background-color: rgba(15, 20, 25, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(63, 72, 82, 0.1);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

body.device-page.light-mode header, body.compare-page.light-mode header {
    background-color: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid rgba(195, 199, 207, 0.3);
}

body.device-page header .nav-container, body.compare-page header .nav-container {
    position: relative;
}

body.device-page .mobile-menu-toggle, body.compare-page .mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--md-on-surface);
    cursor: pointer;
    padding: 0.5rem;
}

body.device-page .mobile-menu-toggle .material-symbols-outlined, body.compare-page .mobile-menu-toggle .material-symbols-outlined {
    font-size: 1.75rem;
}

/* Theme toggle button */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--md-outline-variant);
    color: var(--md-on-surface-variant);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--md-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 2.25rem;
    height: 2.25rem;
}

.theme-toggle:hover {
    background-color: var(--md-surface-container-high);
    color: var(--md-primary);
    border-color: var(--md-primary);
}

.theme-toggle .material-symbols-outlined {
    font-size: 1.15rem;
}

body.device-page .main-nav a {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.3px;
    transition: color 0.2s;
}

body.device-page .main-nav a.active-nav {
    color: var(--md-primary);
    border-bottom: 2px solid var(--md-primary);
    padding-bottom: 2px;
}


/* ═══════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════ */
.spec-sidebar {
    position: fixed;
    left: 0;
    top: 5rem;  /* below the sticky header */
    height: calc(100vh - 5rem);
    width: var(--sidebar-width);
    background-color: var(--md-surface-container-low);
    border-radius: 0 var(--md-radius-2xl) var(--md-radius-2xl) 0;
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    box-shadow: 8px 0 40px var(--md-sidebar-shadow);
    z-index: 40;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--md-surface-container-highest) transparent;
}

.spec-sidebar::-webkit-scrollbar {
    width: 4px;
}
.spec-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.spec-sidebar::-webkit-scrollbar-thumb {
    background: var(--md-surface-container-highest);
    border-radius: 4px;
}

.sidebar-header {
    padding: 0 1.5rem 2rem;
}

.sidebar-header h3 {
    color: var(--md-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin: 0;
}

.sidebar-header p {
    color: var(--md-outline);
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 0.25rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.5rem;
    color: var(--md-outline);
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-decoration: none;
    border-left: 4px solid transparent;
    transition: all 0.25s ease;
}

.sidebar-nav a:hover {
    background-color: var(--md-surface-container-high);
    color: var(--md-on-surface-variant);
}

.sidebar-nav a.active {
    background: linear-gradient(to right, rgba(152, 203, 255, 0.2), transparent);
    color: var(--md-primary);
    border-left-color: var(--md-primary-container);
}

body.device-page.light-mode .sidebar-nav a.active {
    background: linear-gradient(to right, rgba(0, 98, 157, 0.08), transparent);
}

body.device-page.light-mode .sidebar-nav a:hover {
    background-color: var(--md-surface-container);
}

.sidebar-nav a .material-symbols-outlined {
    font-size: 1.25rem;
}


/* ═══════════════════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════════════════════════════════ */
.device-main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem 1.5rem 2rem;
}

.device-content {
    margin-left: calc(var(--sidebar-width) + 2rem);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}


/* ═══════════════════════════════════════════════════════════════════════
   HERO SECTION
   ═══════════════════════════════════════════════════════════════════════ */
.device-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--md-radius-2xl);
    background-color: var(--md-surface-container-low);
    border: 1px solid rgba(63, 72, 82, 0.1);
    min-height: 480px;
    display: flex;
    align-items: center;
}

/* Radial glow behind the hero */
.device-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 60% 50%, var(--md-hero-glow) 0%, transparent 70%);
    pointer-events: none;
}

.hero-inner {
    display: flex;
    flex-direction: row;
    width: 100%;
    align-items: center;
    padding: 2rem 3rem;
    gap: 3rem;
    position: relative;
    z-index: 1;
}

/* Device image area */
.hero-image-wrap {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Soft blue glow behind the device image */
.hero-image-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, var(--md-hero-image-glow) 0%, transparent 70%);
    border-radius: var(--md-radius-full);
    filter: blur(80px);
    opacity: 0.4;
}

.hero-image-wrap img {
    position: relative;
    z-index: 2;
    max-width: 360px;
    object-fit: contain;
    filter: drop-shadow(0 30px 30px var(--md-image-shadow));
    transform: scale(1);
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), z-index 0.4s;
    cursor: zoom-in;
}

/* Swing keyframe: swings out left to clear, then smoothly lands overlapping the front image */
@keyframes swingToFront {
    /* Resting state */
    0%   { transform: scale(0.90) translateX(-110px) rotate(0deg);  }
    /* Swings out left and tilts to 'clear' the other phone */
    40%  { transform: scale(0.95) translateX(-170px) rotate(-8deg);  }
    /* Smoothly scales up and overlaps the front phone */
    100% { transform: scale(1.05) translateX(-25px)  rotate(0deg);  }
}

/* Smooth return when hover is removed (uses transition, not keyframe) */
.hero-image-wrap.staggered {
    height: 400px; /* Reserve height since children are absolute */
}

.hero-image-wrap.staggered img {
    position: absolute;
    inset: 0;
    margin: auto;
    max-height: 100%;
    width: auto;
    will-change: transform;
    transition: transform 0.55s cubic-bezier(0.2, 0, 0, 1), z-index 0.4s;
}

.hero-image-wrap.staggered #d-image-back {
    transform: scale(0.9) translateX(-110px) rotate(0deg);
    z-index: 1;
    filter: drop-shadow(0 20px 20px var(--md-image-shadow)) brightness(0.7);
}

.hero-image-wrap.staggered #d-image-front {
    transform: scale(1) translateX(40px);
    z-index: 2;
}

/* Hovering: fire the swing animation on the back image */
/* Hovering: fire the swing animation on the back image via JS state */
@media (hover: hover) {
    .hero-image-wrap.staggered[data-desktop-state="hovered"] #d-image-back {
        animation: swingToFront 0.7s cubic-bezier(0.2, 0, 0, 1) forwards;
        transition: none; /* let the keyframe fully own the motion */
        z-index: 3;
        filter: drop-shadow(0 40px 40px var(--md-image-shadow)) brightness(1);
    }

    .hero-image-wrap.staggered[data-desktop-state="hovered"] #d-image-front {
        /* Push the front image slightly right and scale it down to sit behind */
        transform: scale(0.9) translateX(70px);
        z-index: 1;
        filter: drop-shadow(0 15px 15px var(--md-image-shadow)) brightness(0.8);
    }
    
    /* Unhovering: fire the shuffle arc on the front image to return without clipping */
    .hero-image-wrap.staggered[data-desktop-state="unhovered"] #d-image-front {
        animation: desktopReturnFront 0.7s cubic-bezier(0.2, 0, 0, 1) forwards;
        transition: none;
        z-index: 2;
    }
}

@keyframes desktopReturnFront {
    0%   { transform: scale(0.9) translateX(70px) rotate(0deg); }
    40%  { transform: scale(0.95) translateX(150px) rotate(8deg); }
    100% { transform: scale(1) translateX(40px) rotate(0deg); }
}

/* Single image fallback */
.hero-image-wrap:not(.staggered) img {
    max-height: 400px;
}
.hero-image-wrap:not(.staggered) img:hover {
    transform: scale(1.03);
}


/* Hero text/info area */
.hero-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 480px;
    width: 100%;
}

/* Chips row (brand + release date) */
.hero-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.chip-brand {
    padding: 0.3rem 0.75rem;
    border-radius: var(--md-radius-full);
    background-color: var(--md-secondary-container);
    color: var(--md-on-secondary-container);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.chip-release {
    padding: 0.3rem 0.75rem;
    border-radius: var(--md-radius-full);
    background-color: var(--md-surface-container-highest);
    color: var(--md-on-surface-variant);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.chip-price {
    padding: 0.3rem 0.75rem;
    border-radius: var(--md-radius-full);
    background-color: var(--md-secondary-container);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* Big model name */
.hero-model {
    font-family: 'Manrope', 'Outfit', sans-serif;
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.04em;
    color: var(--md-on-surface);
    margin: 0;
}

.hero-model .model-suffix {
    color: var(--md-primary);
}

/* AKA description */
.hero-description {
    color: var(--md-on-surface-variant);
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    line-height: 1.7;
}

/* CTA button row */
.hero-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.btn-primary-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    background-color: var(--md-primary);
    color: var(--md-on-primary-container);
    border: none;
    border-radius: var(--md-radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 30px var(--md-shadow-color);
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary-cta:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 12px 40px var(--md-shadow-color);
}

.btn-primary-cta:active {
    transform: translateY(0);
}

.btn-secondary-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.75rem;
    background-color: var(--md-surface-container-highest);
    color: var(--md-on-surface);
    border: 1px solid rgba(63, 72, 82, 0.1);
    border-radius: var(--md-radius-full);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-secondary-cta:hover {
    background-color: var(--md-surface-bright);
    transform: translateY(-1px);
}

.btn-secondary-cta:active {
    transform: translateY(0);
}

.btn-primary-cta .material-symbols-outlined,
.btn-secondary-cta .material-symbols-outlined {
    font-size: 1.2rem;
}


/* ─── Quick Glance Stats (inside hero) ────────────────────────────────── */
.quick-glance {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(63, 72, 82, var(--md-border-alpha));
}

.glance-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.glance-stat .stat-label {
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--md-on-surface-variant);
}

.glance-stat .stat-value {
    font-family: 'Manrope', sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--md-on-surface);
}

.glance-stat .stat-value .stat-unit {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--md-primary);
    margin-left: 2px;
}


/* ═══════════════════════════════════════════════════════════════════════
   BENTO GRID
   ═══════════════════════════════════════════════════════════════════════ */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* ─── Bento Card Base ─────────────────────────────────────────────────── */
.bento-card {
    background-color: var(--md-surface-container-high);
    border-radius: var(--md-radius-xl);
    padding: 2rem;
    border: 1px solid rgba(63, 72, 82, var(--md-border-alpha));
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    contain: layout style;
}

.bento-card:hover {
    border-color: rgba(63, 72, 82, 0.15);
    box-shadow: 0 4px 24px var(--md-card-hover-shadow);
}

/* Alternate surface color for visual variety */
.bento-card.surface-low {
    background-color: var(--md-surface-container-low);
}

/* Column span variants */
.bento-card.span-2 {
    grid-column: span 2;
}

.bento-card.span-3 {
    grid-column: span 3;
}

@media (min-width: 768px) {
    .bento-card.row-span-2 {
        grid-row: span 2;
        align-self: start;
    }
}

/* Card header (icon + title) */
.bento-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.bento-header .material-symbols-outlined {
    font-size: 1.5rem;
    color: var(--md-primary);
}

.bento-header h2 {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--md-on-surface);
    margin: 0;
}


/* ─── Card Layout Variants ────────────────────────────────────────────── */

/* Stat columns (e.g., Display card — 3 stats side by side) */
.stat-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

.stat-col .stat-label {
    font-size: 0.65rem;
    color: var(--md-on-surface-variant);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
}

.stat-col .stat-value {
    font-size: 1rem;
    font-weight: 500;
    color: var(--md-on-surface);
}


/* Key-value rows with dividers (e.g., Platform card) */
.kv-rows {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(63, 72, 82, 0.1);
}

.kv-row:last-child {
    border-bottom: none;
}

.kv-row .kv-key {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--md-on-surface-variant);
}

.kv-row .kv-val {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--md-on-surface);
    text-align: right;
    max-width: 60%;
}


/* Big number highlight (e.g., Battery card) */
.big-number {
    font-family: 'Manrope', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--md-on-surface);
    margin-bottom: 0.35rem;
    line-height: 1;
}

.big-number .big-unit {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--md-primary);
    margin-left: 0.25rem;
}

.big-sub {
    color: var(--md-on-surface-variant);
    font-size: 0.85rem;
}

.big-highlight {
    color: var(--md-primary);
    font-weight: 700;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 1rem;
}


/* Icon + text rows (e.g., Storage card) */
.icon-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-row + .icon-row {
    margin-top: 1.5rem;
}

.icon-box {
    width: 3rem;
    height: 3rem;
    border-radius: var(--md-radius-xl);
    background-color: var(--md-surface-container-highest);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.icon-box .material-symbols-outlined {
    color: var(--md-primary);
    font-size: 1.3rem;
}

.icon-row-text .icon-row-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--md-on-surface-variant);
}

.icon-row-text .icon-row-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--md-on-surface);
    margin-top: 0.15rem;
}


/* Nested sub-cards (e.g., Camera Optics card) */
.sub-card {
    padding: 1rem;
    border-radius: var(--md-radius-xl);
    background-color: var(--md-surface-container-low);
    border: 1px solid rgba(63, 72, 82, 0.1);
}

.sub-card + .sub-card {
    margin-top: 0.75rem;
}

.sub-card-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--md-primary);
    margin-bottom: 0.25rem;
}

.sub-card-label.muted {
    color: var(--md-on-surface-variant);
}

.sub-card-value {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--md-on-surface);
}


/* Background watermark icon (e.g., camera card) */
.bento-card .watermark-icon {
    position: absolute;
    bottom: -0.5rem;
    right: -0.5rem;
    font-size: 10rem;
    color: var(--md-primary);
    opacity: 0.03;
    pointer-events: none;
    user-select: none;
    line-height: 1;
}


/* Icon tile grid (e.g., Connectivity card) */
.icon-tile-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.icon-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem 0.75rem;
    background-color: var(--md-surface-container-low);
    border-radius: var(--md-radius-2xl);
    border: 1px solid rgba(63, 72, 82, 0.1);
    text-align: center;
    transition: border-color 0.2s ease;
}

.icon-tile:hover {
    border-color: rgba(63, 72, 82, 0.2);
}

.icon-tile .material-symbols-outlined {
    color: var(--md-primary);
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.icon-tile .tile-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--md-on-surface);
}


/* Stat pair grid (e.g., Body card — 2x2 layout) */
.stat-pair-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.stat-pair .stat-pair-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--md-on-surface-variant);
    margin-bottom: 0.25rem;
}

.stat-pair .stat-pair-value {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--md-on-surface);
}


/* Generic spec rows (fallback for unmapped categories) */
.generic-spec-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 1rem;
    margin-bottom: 0.6rem;
    font-size: 0.85rem;
}

.generic-spec-name {
    color: var(--md-on-surface-variant);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.generic-spec-value {
    color: var(--md-on-surface);
}


/* ═══════════════════════════════════════════════════════════════════════
   FLOATING ACTION BUTTON
   ═══════════════════════════════════════════════════════════════════════ */
.compare-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--md-primary);
    color: var(--md-on-primary-container);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, var(--md-border-alpha));
    border-radius: var(--md-radius-2xl);
    box-shadow: 0 8px 40px var(--md-fab-shadow);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    z-index: 60;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

.compare-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 50px var(--md-fab-shadow);
}

.compare-fab:active {
    transform: scale(0.95);
}

.compare-fab .material-symbols-outlined {
    font-size: 1.3rem;
    font-weight: 700;
}

.compare-fab .fab-label {
    white-space: nowrap;
}


/* ═══════════════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════════════ */
.device-footer {
    background-color: var(--md-surface-container-lowest);
    border-top: 1px solid rgba(63, 72, 82, var(--md-border-alpha));
    margin-top: 5rem;
    padding: 3rem 2rem;
}

.footer-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.footer-brand .footer-logo {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--md-on-surface);
    letter-spacing: -0.5px;
}

.footer-brand .footer-logo span {
    color: var(--md-primary);
}

.footer-brand .footer-copy {
    color: var(--md-outline);
    font-size: 0.7rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    margin-top: 0.25rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
}

.footer-links a {
    color: var(--md-outline);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--md-primary);
}

.footer-social {
    display: flex;
    gap: 0.75rem;
}

.footer-social-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--md-radius-full);
    background-color: var(--md-surface-container);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(63, 72, 82, 0.1);
    cursor: pointer;
    transition: all 0.2s ease;
}

.footer-social-btn .material-symbols-outlined {
    font-size: 1.1rem;
    color: var(--md-outline);
    transition: color 0.2s ease;
}

.footer-social-btn:hover {
    background-color: var(--md-surface-container-high);
}

.footer-social-btn:hover .material-symbols-outlined {
    color: var(--md-primary);
}


/* ═══════════════════════════════════════════════════════════════════════
   LOADING / ERROR STATE
   ═══════════════════════════════════════════════════════════════════════ */
.device-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    color: var(--md-on-surface-variant);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    gap: 1rem;
}

.device-loader .material-symbols-outlined {
    font-size: 2.5rem;
    color: var(--md-primary);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}


/* ═══════════════════════════════════════════════════════════════════════
   ENTRANCE ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bento-card {
    opacity: 0;
    transform: translateY(16px);
}

.bento-card.animate-in {
    animation: fadeInUp 0.5s ease-out both;
}

.device-hero {
    animation: fadeInUp 0.6s ease-out both;
}


/* ═══════════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════ */

/* Tablets and below — hide sidebar, full-width content */
@media (max-width: 1023px) {
    .spec-sidebar {
        display: none;
    }

    .device-content {
        margin-left: 0;
    }
}

/* Medium screens — 2-column bento */
@media (max-width: 1279px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bento-card.span-2 {
        grid-column: span 2;
    }

    .bento-card.span-3 {
        grid-column: span 2;
    }

    .hero-model {
        font-size: 2.75rem;
    }
}

/* Small tablets / large phones */
@media (max-width: 767px) {
    .bento-grid {
        grid-template-columns: 1fr;
    }

    .bento-card.span-2,
    .bento-card.span-3 {
        grid-column: span 1;
    }

    .hero-inner {
        flex-direction: column;
        padding: 2rem 1.5rem;
        gap: 2rem;
    }

    .hero-image-wrap {
        flex: none; /* Fixes 0 height issue in flex column */
        width: 100%;
    }

    .hero-image-wrap.staggered {
        height: 320px;
    }

    .hero-image-wrap.staggered #d-image-back {
        transform: scale(0.85) translateX(-60px) rotate(0deg);
        filter: brightness(0.7);
        z-index: 1;
    }

    .hero-image-wrap.staggered #d-image-front {
        transform: scale(0.95) translateX(30px);
        filter: brightness(1);
        z-index: 2;
    }

    /* Mobile Gallery States */
    .hero-image-wrap.staggered[data-gallery-state="front-active"] #d-image-back {
        transform: scale(0.85) translateX(-60px) rotate(0deg);
        z-index: 1;
        filter: brightness(0.7);
    }
    .hero-image-wrap.staggered[data-gallery-state="front-active"] #d-image-front {
        transform: scale(0.95) translateX(30px);
        z-index: 2;
        filter: brightness(1);
    }

    .hero-image-wrap.staggered[data-gallery-state="back-active-left"] #d-image-back {
        animation: shuffleInFromLeft 0.6s cubic-bezier(0.2, 0, 0, 1) forwards;
        z-index: 3;
        filter: brightness(1);
    }
    .hero-image-wrap.staggered[data-gallery-state="back-active-left"] #d-image-front {
        transform: scale(0.85) translateX(60px);
        z-index: 1;
        filter: brightness(0.7);
    }

    .hero-image-wrap.staggered[data-gallery-state="front-active-right"] #d-image-front {
        animation: shuffleInFromRight 0.6s cubic-bezier(0.2, 0, 0, 1) forwards;
        z-index: 3;
        filter: brightness(1);
    }
    .hero-image-wrap.staggered[data-gallery-state="front-active-right"] #d-image-back {
        transform: scale(0.85) translateX(-60px);
        z-index: 1;
        filter: brightness(0.7);
    }

    @keyframes shuffleInFromLeft {
        0%   { transform: scale(0.85) translateX(-60px) rotate(0deg);  }
        40%  { transform: scale(0.90) translateX(-140px) rotate(-8deg);  }
        100% { transform: scale(0.95) translateX(-30px) rotate(0deg);  }
    }

    @keyframes shuffleInFromRight {
        0%   { transform: scale(0.85) translateX(60px) rotate(0deg);  }
        40%  { transform: scale(0.90) translateX(140px) rotate(8deg);  }
        100% { transform: scale(0.95) translateX(30px) rotate(0deg);  }
    }

    .mobile-gallery-dots {
        display: flex;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
        position: absolute;
        bottom: 0;
        z-index: 10;
    }

    .gallery-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        border: 1px solid var(--md-outline);
        background: transparent;
        transition: all 0.3s ease;
    }

    .gallery-dot.active {
        background: var(--md-primary);
        border-color: var(--md-primary);
        transform: scale(1.2);
    }

    .hero-image-wrap img {
        max-width: 220px;
    }

    .hero-model {
        font-size: 2.25rem;
    }

    .hero-actions {
        flex-direction: column;
    }

    .stat-columns {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .icon-tile-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .quick-glance {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Mobile Header/Nav Styles */
    body.device-page .mobile-menu-toggle, body.compare-page .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    body.device-page .main-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--md-surface-container-high);
        border-bottom: 1px solid rgba(63, 72, 82, 0.1);
        flex-direction: column;
        display: none;
        padding: 0.5rem 0;
        box-shadow: 0 10px 30px var(--md-mobile-menu-shadow);
        z-index: 101;
    }

    body.device-page .main-nav.show {
        display: flex;
    }

    body.device-page .main-nav a {
        margin: 0;
        padding: 1.25rem 2rem;
        border-bottom: 1px solid rgba(63, 72, 82, 0.05);
        color: var(--md-on-surface);
        font-size: 1.1rem;
    }
    
    body.device-page .main-nav a.active-nav {
        border-bottom: 1px solid rgba(63, 72, 82, 0.05);
        border-left: 4px solid var(--md-primary);
        background: linear-gradient(to right, rgba(152, 203, 255, 0.05), transparent);
        padding-bottom: 1.25rem;
    }

    /* FAB: icon-only on mobile */
    .compare-fab .fab-label {
        display: none;
    }

    .compare-fab {
        padding: 1rem;
        border-radius: var(--md-radius-2xl);
    }

    /* Footer stacks */
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }

    .device-main {
        padding: 1.5rem 1rem;
    }

    .bento-card {
        padding: 1.5rem;
    }
}

/* Very small phones */
@media (max-width: 374px) {
    .hero-model {
        font-size: 1.8rem;
    }

    .quick-glance {
        grid-template-columns: 1fr 1fr;
    }

    .stat-pair-grid {
        grid-template-columns: 1fr;
    }
}


/* -----------------------------------------------------------------------
   LIGHTBOX DIALOG
   ----------------------------------------------------------------------- */
.lightbox-dialog {
    border: none;
    background: transparent;
    padding: 0;
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    margin: 0;
}

.lightbox-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lightbox-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    align-items: center;
    justify-content: center;
}

.lightbox-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 10;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.close-btn {
    position: absolute;
    top: 2rem;
    right: 2rem;
}

.lightbox-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 0 2rem;
    box-sizing: border-box;
}

.lightbox-image-wrapper {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.lightbox-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.5));
    user-select: none;
    -webkit-user-drag: none;
}

.lightbox-counter {
    position: absolute;
    bottom: 2rem;
    color: white;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.5rem 1rem;
    border-radius: var(--md-radius-full);
}

/* -----------------------------------------------------------------------
   ACCESSIBILITY & POLISH ANIMATIONS
   ----------------------------------------------------------------------- */

.lightbox-dialog[open] {
    animation: lightboxIn 0.3s ease-out;
}

@keyframes lightboxIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ───────────────────────────────────────────────────────────────────────
   COMPARISON MODAL & FAB
   ─────────────────────────────────────────────────────────────────────── */

.compare-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--md-primary);
    color: var(--md-on-primary-container) !important;
    padding: 1rem 1.75rem;
    border-radius: var(--md-radius-full);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none !important;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    box-shadow: 0 8px 32px var(--md-fab-shadow);
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
}

.compare-fab:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 40px var(--md-fab-shadow);
    filter: brightness(1.1);
}

.compare-fab .material-symbols-outlined {
    font-size: 1.5rem;
}

.compare-dialog {
    padding: 0;
    border: none;
    border-radius: var(--md-radius-2xl);
    background-color: var(--md-surface-container-high);
    color: var(--md-on-surface);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 90%;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    overflow: visible; /* Allow autocomplete results to spilt out of dialog if needed */
}

.compare-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.compare-modal-content {
    display: flex;
    flex-direction: column;
}

.compare-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--md-outline-variant);
}

.compare-modal-header h3 {
    margin: 0;
    font-family: 'Manrope', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--md-primary);
}

.close-modal-btn {
    background: transparent;
    border: none;
    color: var(--md-on-surface-variant);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.close-modal-btn:hover {
    color: var(--md-primary);
}

.compare-modal-body {
    padding: 2rem;
}

.compare-modal-body p {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--md-on-surface-variant);
}

.search-box-wrapper {
    position: relative;
    background-color: var(--md-surface-container-lowest);
    border: 1px solid var(--md-outline-variant);
    border-radius: var(--md-radius-xl);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box-wrapper:focus-within {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 2px rgba(152, 203, 255, 0.2);
}

.search-box-wrapper .search-icon {
    color: var(--md-on-surface-variant);
    font-size: 1.25rem;
}

#compare-search-input {
    background: transparent;
    border: none;
    color: var(--md-on-surface);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    padding: 1rem 0;
    width: 100%;
    outline: none;
}

.autocomplete-results {
    width: 100%;
    margin-top: 0.5rem;
    background-color: var(--md-surface-container-highest);
    border-radius: var(--md-radius-xl);
    max-height: 40vh;
    overflow-y: auto;
    z-index: 10;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
    display: none;
    border: 1px solid var(--md-outline-variant);
}

.autocomplete-result-item {
    padding: 1rem 1.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--md-on-surface);
}

.autocomplete-result-item:hover {
    background-color: var(--md-primary-container);
    color: var(--md-on-primary-container);
}

.autocomplete-result-item:last-child {
    border-radius: 0 0 var(--md-radius-xl) var(--md-radius-xl);
}

@media (max-width: 767px) {
    .compare-fab .fab-label {
        display: none;
    }
    .compare-fab {
        padding: 1rem;
        bottom: 1.5rem;
        right: 1.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bento-card,
    .device-hero,
    .hero-image-wrap.staggered img {
        animation: none !important;
        transition: none !important;
    }
    
    .hero-image-wrap.staggered:hover #d-image-back,
    .hero-image-wrap.staggered:hover #d-image-front {
        animation: none !important;
        transition: none !important;
    }

    .lightbox-dialog[open],
    .compare-dialog[open] {
        animation: none !important;
    }
}
