/* ===== Mobile Responsive Styles ===== */
/* Breakpoints: 768px (tablet), 480px (mobile) */

/* Scale site to 65% on mobile */
@media (max-width: 768px) {
    html {
        font-size: 65%;
    }
}

/* Prevent layout shift on zoom */
html {
    min-width: 320px;
}

body {
    min-width: 320px;
    width: 100%;
}

/* Fix horizontal overflow on specific sections, not body (sticky needs no overflow on parent) */
.hero,
.terminal-section,
.panels-section,
.sticky-section {
    overflow-x: hidden;
    max-width: 100vw;
}

/* All sections should not exceed viewport */
section,
.projects-section,
.modal-content {
    max-width: 100vw;
    box-sizing: border-box;
}

/* ===== Tablet (max-width: 768px) ===== */
@media (max-width: 768px) {
    /* === Top Bar === */
    .top-bar {
        left: 16px;
        right: 16px;
        top: 8px;
        height: 44px;
    }

    .top-bar-pill {
        padding: 8px 20px;
        gap: 18px;
        border-radius: 40px;
    }

    .top-bar-pill a {
        font-size: 0.6rem;
    }

    .top-bar-logo {
        font-size: 0.9rem;
    }

    .top-bar-menu {
        display: flex;
        width: 36px;
        height: 36px;
    }

    /* === Hero Section === */
    .hero {
        min-height: 100svh;
    }

    .hero-title-wrapper {
        top: 28%;
    }

    .hero-title {
        font-size: clamp(5rem, 22vw, 12rem);
    }

    .title-labels {
        display: none;
    }

    /* Bio text - left side */
    .hero-bio {
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        max-width: 130px;
    }

    .hero-bio p {
        font-size: 0.75rem;
        line-height: 1.4;
    }

    /* Head - much higher, overlapping text */
    .hero-head {
        bottom: 120px;
    }

    .head-img {
        width: 100vw;
        max-width: 620px;
        min-width: 350px;
    }

    /* Contact button - right side, lower */
    .contact-btn {
        position: absolute;
        right: 16px;
        left: auto;
        top: 65%;
        transform: translateY(-50%);
        padding: 12px 24px;
        font-size: 0.8rem;
    }

    .contact-btn:hover {
        transform: translateY(-50%) rotate(-8deg);
    }

    /* === Terminal Section === */
    .terminal-section {
        height: 120px;
    }

    .terminal-content {
        padding: 12px 16px;
    }

    .terminal-line {
        font-size: 10px;
        line-height: 1.5;
    }

    /* === Panels Section (What I Do) === */
    .panels-section {
        padding: 60px 16px;
        min-height: auto;
    }

    .panels-title {
        font-size: 1.8rem;
        margin-bottom: 40px;
    }

    .panels-container {
        height: 500px;
        gap: 10px;
        max-width: 100%;
    }

    .panel {
        flex: 0 0 55px;
        border-radius: 35px;
        padding-top: 14px;
    }

    .panel-badge {
        width: 40px;
        height: 40px;
        margin-bottom: 12px;
    }

    .panel-badge img {
        width: 22px;
        height: 22px;
    }

    .panel-name {
        font-size: 0.6rem;
    }

    .panel-info {
        padding: 16px;
    }

    .panel-info-title {
        font-size: 0.8rem;
    }

    .panel-info-desc {
        font-size: 0.65rem;
    }

    .panel-btn {
        padding: 10px 18px;
        font-size: 0.65rem;
    }

    /* Hide FX effects on mobile */
    .vk-fx,
    .web-fx,
    .ai-fx,
    #fx-overlay,
    #pay-fx-overlay {
        display: none;
    }

    /* === Sticky Plate Section === */
    .sticky-section {
        padding: 10px;
    }

    .sticky-plate {
        padding: 40px 20px;
        border-radius: 24px;
        gap: 10px;
    }

    .plate-main-title {
        font-size: 2rem;
        margin-bottom: 30px;
        -webkit-text-stroke: 0.5px #111;
    }

    .plate-step {
        flex-direction: column;
        padding: 30px 0;
        padding-left: 0;
        gap: 20px;
    }

    .step-number {
        font-size: 4rem;
        min-width: auto;
    }

    .step-content {
        padding-top: 0;
        max-width: 100%;
    }

    .step-title {
        font-size: 1.1rem;
    }

    .step-text {
        font-size: 0.9rem;
    }

    /* === Projects Section - minimal changes === */
    .projects-section {
        padding: 60px 16px;
    }

    /* === Contact Card === */
    .stack-card--contact {
        min-height: auto;
        padding: 30px 16px;
    }

    .stack-card-contact-content {
        flex-direction: column;
        gap: 20px;
    }

    .stack-card-contact-left,
    .stack-card-contact-right {
        width: 100%;
    }

    .stack-card-contact-title {
        font-size: 1rem;
        line-height: 1.3;
        text-align: center;
    }

    .contact-form-row {
        flex-direction: column;
        gap: 10px;
    }

    .contact-input,
    .contact-textarea {
        padding: 12px 14px;
        font-size: 0.85rem;
    }

    .contact-textarea {
        min-height: 80px;
    }

    .contact-submit {
        width: 100%;
        padding: 12px;
    }

    .contact-decor {
        display: none;
    }

    /* === Modals === */
    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .modal-close {
        top: 16px;
        left: 16px;
        width: 40px;
        height: 40px;
        font-size: 2rem;
    }

    .modal-header {
        padding: 20px;
    }

    .modal-logo {
        width: 40px;
    }

    .modal-fx {
        display: none;
    }

    .modal-article {
        padding: 20px 24px 40px;
        max-height: calc(100vh - 80px);
    }

    .article-title {
        font-size: 2rem;
        margin-bottom: 20px;
    }

    .article-lead {
        font-size: 1rem;
        margin-bottom: 30px;
    }

    .article-heading {
        font-size: 1.2rem;
        margin-top: 40px;
        margin-bottom: 20px;
    }

    .article-subheading {
        font-size: 1rem;
    }

    .article-text {
        font-size: 0.95rem;
    }

    .article-row {
        flex-direction: column;
    }

    .article-video-9-16 {
        width: 100%;
        max-width: 250px;
        height: auto;
        aspect-ratio: 9/16;
        margin: 20px auto;
    }
}

/* ===== Mobile Small (max-width: 480px) ===== */
@media (max-width: 480px) {
    /* === Top Bar === */
    .top-bar {
        left: 10px;
        right: 10px;
        top: 6px;
        height: 40px;
    }

    .top-bar-pill {
        padding: 6px 14px;
        gap: 12px;
    }

    .top-bar-pill a {
        font-size: 0.5rem;
    }

    .top-bar-logo {
        font-size: 0.85rem;
    }

    .top-bar-menu {
        width: 32px;
        height: 32px;
    }

    .top-bar-menu span {
        width: 14px;
    }

    /* === Hero === */
    .hero-title-wrapper {
        top: 25%;
    }

    .hero-title {
        font-size: clamp(4rem, 20vw, 9rem);
    }

    .hero-bio {
        left: 10px;
        max-width: 110px;
    }

    .hero-bio p {
        font-size: 0.65rem;
    }

    .hero-head {
        bottom: 100px;
    }

    .head-img {
        width: 100vw;
        min-width: 320px;
        max-width: 500px;
    }

    .contact-btn {
        right: 10px;
        top: 62%;
        padding: 10px 18px;
        font-size: 0.7rem;
    }

    /* === Panels === */
    .panels-section {
        padding: 40px 10px;
    }

    .panels-title {
        font-size: 1.5rem;
        margin-bottom: 30px;
    }

    .panels-container {
        height: 450px;
        gap: 6px;
    }

    .panel {
        flex: 0 0 48px;
        border-radius: 30px;
        padding-top: 12px;
    }

    .panel-badge {
        width: 36px;
        height: 36px;
        margin-bottom: 10px;
    }

    .panel-badge img {
        width: 20px;
        height: 20px;
    }

    .panel-name {
        font-size: 0.5rem;
    }

    .panel-info {
        padding: 12px;
    }

    .panel-info-title {
        font-size: 0.7rem;
    }

    .panel-info-desc {
        font-size: 0.55rem;
    }

    .panel-btn {
        padding: 8px 12px;
        font-size: 0.55rem;
    }

    /* === Sticky Plate === */
    .sticky-section {
        padding: 8px;
    }

    .sticky-plate {
        padding: 30px 16px;
        border-radius: 20px;
    }

    .plate-main-title {
        font-size: 1.5rem;
        margin-bottom: 24px;
    }

    .plate-step {
        padding: 24px 0;
        gap: 16px;
    }

    .step-number {
        font-size: 3rem;
    }

    .step-title {
        font-size: 1rem;
    }

    .step-text {
        font-size: 0.85rem;
        line-height: 1.6;
    }

    /* === Projects - minimal === */
    .projects-section {
        padding: 40px 12px;
    }

    /* === Contact Card === */
    .stack-card--contact {
        padding: 24px 14px;
    }

    .stack-card-contact-title {
        font-size: 0.9rem;
    }

    .contact-input,
    .contact-textarea {
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .contact-textarea {
        min-height: 70px;
    }

    /* === Modals === */
    .modal-article {
        padding: 16px 20px 30px;
    }

    .article-title {
        font-size: 1.6rem;
    }

    .article-lead {
        font-size: 0.95rem;
    }

    .article-heading {
        font-size: 1.1rem;
    }

    .article-subheading {
        font-size: 0.95rem;
    }

    .article-text {
        font-size: 0.9rem;
    }

    .article-video-placeholder {
        border-radius: 12px;
        margin: 20px 0;
    }
}

/* ===== Touch Device Improvements ===== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .contact-btn,
    .stack-card-btn,
    .panel-btn {
        min-height: 48px;
    }
}

/* ===== Safe Area for notched devices ===== */
@supports (padding: max(0px)) {
    .top-bar {
        top: max(12px, env(safe-area-inset-top));
        left: max(16px, env(safe-area-inset-left));
        right: max(16px, env(safe-area-inset-right));
    }

    .modal-article {
        padding-bottom: max(40px, env(safe-area-inset-bottom));
    }
}

/* ===== Landscape Mobile ===== */
@media (max-width: 900px) and (orientation: landscape) {
    .hero {
        min-height: 100svh;
    }

    .hero-title {
        font-size: clamp(2.5rem, 10vw, 5rem);
    }

    .hero-title-wrapper {
        top: 8%;
    }

    .hero-bio {
        top: 50%;
        left: 16px;
    }

    .hero-head {
        bottom: -50px;
    }

    .head-img {
        max-width: 350px;
    }

    .contact-btn {
        top: 50%;
        right: 16px;
    }
}
