/* Global responsive system: keeps layout rhythm consistent across pages/devices */

:root {
    --container-max: 1400px;
}

.container {
    max-width: var(--container-max);
    width: min(var(--container-max), 100% - 2 * clamp(16px, 3.2vw, 48px));
    margin-inline: auto;
    padding-inline: 0;
}

/* Prevent fixed sections from being cut by mobile browser UI bars */
.hero,
.about-hero,
.contact-hero {
    min-height: 100svh;
}

/* Large desktop */
@media (min-width: 1680px) {
    :root {
        --container-max: 1520px;
    }
}

/* Laptop / desktop */
@media (max-width: 1280px) {
    :root {
        --container-max: 1200px;
    }

    .portfolio-item {
        height: 420px;
        min-height: 420px;
    }

    .portfolio-content {
        padding: 2.25rem 2.5rem;
    }

    .hero-title {
        font-size: clamp(2.7rem, 7vw, 5.3rem);
    }
}

/* Tablet landscape */
@media (max-width: 1024px) {
    :root {
        --container-max: 100%;
    }

    .navbar .container {
        height: 68px;
    }

    .hero {
        padding: 104px 0 72px;
    }

    .hero-stats {
        gap: clamp(16px, 2.6vw, 28px);
        flex-wrap: wrap;
    }

    .portfolio-header {
        padding: 5.5rem 0 2.5rem;
    }

    .portfolio-main {
        padding: 3rem 0 4.5rem;
    }

    .modal-content {
        width: calc(100% - 1.5rem);
        max-height: calc(100svh - 1.5rem);
        margin: 0.75rem auto;
    }

    .about-hero .hero-content,
    .contact-layout {
        gap: 1.5rem;
    }
}

/* Tablet portrait / large phones */
@media (max-width: 768px) {
    .navbar .container {
        height: 64px;
    }

    .nav-menu {
        top: 64px;
        padding: 0.875rem 0.75rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .hero {
        padding: 92px 0 56px;
    }

    .hero-title {
        font-size: clamp(2.2rem, 10.5vw, 3.4rem);
        line-height: 1;
    }

    .hero-subtitle {
        font-size: 0.98rem;
        max-width: 100%;
    }

    .hero-actions {
        width: 100%;
    }

    .hero-actions .btn {
        width: 100%;
    }

    .stat-number {
        font-size: clamp(2rem, 9vw, 2.6rem);
    }

    .portfolio-item {
        border-radius: 0;
    }

    .portfolio-image {
        height: clamp(210px, 45vw, 320px);
    }

    .portfolio-content {
        padding: 1.25rem 1.25rem 1.5rem;
    }

    .portfolio-meta {
        gap: 0.625rem;
        margin-bottom: 0.875rem;
    }

    .portfolio-title {
        font-size: clamp(1.3rem, 6.6vw, 1.7rem);
        margin-bottom: 0.9rem;
    }

    .portfolio-description {
        font-size: 0.94rem;
        line-height: 1.68;
    }

    .modal-main-image {
        padding: 0.625rem 0.75rem;
    }

    .modal-main-image img,
    .modal-main-media,
    .progressive-media {
        max-height: 52svh;
    }

    .modal-gallery-thumbs {
        padding: 0.625rem 0.75rem;
        gap: 0.5rem;
    }

    .modal-thumb-btn {
        width: 76px;
        height: 48px;
    }

    .modal-header,
    .modal-description,
    .modal-tags,
    .modal-videos,
    .modal-footer {
        padding-inline: 0.75rem !important;
    }

    .about-hero,
    .contact-hero {
        padding-top: 82px;
    }

    .about-hero .hero-content,
    .contact-main .contact-layout {
        grid-template-columns: 1fr !important;
    }
}

/* Common mobile widths (390/393/412 etc.) */
@media (max-width: 576px) {
    .container {
        width: min(var(--container-max), 100% - 24px);
    }

    .logo {
        font-size: 1rem;
    }

    .logo::before {
        left: -12px;
        width: 6px;
        height: 6px;
    }

    .hero {
        padding: 86px 0 48px;
    }

    .hero-badge {
        font-size: 0.68rem;
        padding: 8px 12px;
    }

    .hero-stats {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .portfolio-filters {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.375rem;
        scrollbar-width: none;
    }

    .portfolio-filters::-webkit-scrollbar {
        display: none;
    }

    .filter-btn {
        white-space: nowrap;
    }

    .modal-close {
        top: 0.75rem;
        right: 0.75rem;
        width: 36px;
        height: 36px;
    }
}

/* Small phones */
@media (max-width: 420px) {
    .container {
        width: min(var(--container-max), 100% - 20px);
    }

    .hero-title {
        font-size: clamp(2rem, 11.2vw, 2.6rem);
    }

    .hero-stats {
        grid-template-columns: 1fr;
    }

    .portfolio-image {
        height: 200px;
    }

    .portfolio-content {
        padding: 1rem 0.95rem 1.2rem;
    }

    .modal-content {
        width: calc(100% - 0.75rem);
        margin: 0.375rem auto;
        max-height: calc(100svh - 0.75rem);
    }
}

/* Mobile reading mode: prioritize one-column reading and touch-friendly interactions */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    html {
        -webkit-text-size-adjust: 100%;
    }

    body {
        background-attachment: scroll;
    }

    .bg-grid,
    .particles-container,
    .mouse-trail-container {
        display: none;
    }

    body::after {
        opacity: 0.16;
    }

    .hero,
    .about-hero,
    .contact-hero {
        min-height: auto;
    }

    .hero,
    .about-hero,
    .contact-hero,
    .portfolio-main,
    .about-main,
    .contact-main {
        scroll-margin-top: 72px;
    }

    .reveal-on-scroll {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .hero {
        padding: 80px 0 40px;
    }

    .hero-title {
        font-size: clamp(1.9rem, 10vw, 2.8rem);
        line-height: 1.04;
    }

    .hero-description,
    .hero-subtitle {
        font-size: 0.98rem;
        line-height: 1.75;
    }

    .hero-actions,
    .contact-buttons {
        width: 100%;
    }

    .hero-actions .btn,
    .contact-btn,
    .btn {
        width: 100%;
        justify-content: center;
    }

    .filter-btn {
        width: auto;
    }

    .menu-toggle,
    .back-to-top,
    .modal-close,
    .modal-media-arrow {
        width: auto;
        justify-content: center;
    }

    .nav-menu a,
    .filter-btn,
    .btn,
    .contact-btn,
    .menu-toggle,
    .back-to-top,
    .modal-close,
    .portfolio-item {
        min-height: 44px;
    }

    .nav-menu a,
    .filter-btn,
    .btn,
    .contact-btn,
    .menu-toggle,
    .back-to-top,
    .modal-close,
    .portfolio-item {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .hero-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
        padding: 1.5rem 0;
        margin-top: 1.5rem;
    }

    .stat-card {
        padding: 1rem;
        gap: 0.75rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
    }

    .stat-number {
        font-size: 1.45rem;
    }

    .stat-label {
        font-size: 0.68rem;
    }

    .about-hero > .container {
        margin-top: 0;
    }

    .hero-content {
        min-height: auto;
        transform: none;
        padding-top: 1rem;
    }

    .hero-right {
        position: relative;
        inset: auto;
        transform: none;
        margin-bottom: 1rem;
        align-items: center;
    }

    .hero-left {
        margin-top: 0;
    }

    .profile-visual {
        --top-crop-px: 0px;
        width: min(100%, 720px);
        aspect-ratio: 4 / 3;
        max-height: 36svh;
        margin-top: 0;
    }

    .hero-overlay-panel {
        transform: none;
    }

    .hero-orb {
        opacity: 0.08;
        filter: blur(72px);
    }

    .about-main,
    .contact-main,
    .portfolio-main {
        padding-top: 2.5rem;
        padding-bottom: 3.5rem;
    }

    .about-section {
        margin-bottom: 3.5rem;
    }

    .timeline-card,
    .contact-card,
    .form-card {
        padding: 1rem;
    }

    .timeline-item {
        margin-bottom: 1rem;
    }

    .timeline-card h3 {
        font-size: 1.05rem;
    }

    .timeline-company,
    .timeline-tasks li,
    .hero-description p,
    .faq-item p,
    .contact-methods p,
    .method-item,
    .modal-description > p {
        font-size: 0.95rem;
        line-height: 1.7;
    }

    .contact-layout {
        gap: 1.25rem;
        margin-bottom: 3.5rem;
    }

    .contact-sidebar,
    .contact-form-wrapper {
        gap: 1rem;
    }

    .contact-methods h3 {
        margin-bottom: 0.75rem;
    }

    .method-item {
        padding: 0.875rem;
    }

    .form-group input,
    .form-group textarea,
    .form-group select,
    .contact-form input,
    .contact-form textarea,
    .contact-form select {
        font-size: 16px;
    }

    .portfolio-header {
        min-height: auto;
        padding: 4.25rem 0 1.25rem;
    }

    .page-title {
        font-size: clamp(1.9rem, 8vw, 2.6rem);
        max-width: none;
    }

    .page-subtitle {
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }

    .portfolio-filters {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.35rem;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .portfolio-filters::-webkit-scrollbar {
        display: none;
    }

    .portfolio-item {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
        border-radius: 0;
        opacity: 1;
        transform: none;
        margin-bottom: 1rem;
    }

    body.scroll-focus-mode .portfolio-item {
        opacity: 1;
        transform: none;
        filter: none;
        transition: opacity 0.25s ease;
    }

    .portfolio-item.is-visible {
        transform: none;
    }

    .portfolio-item:focus-visible,
    .filter-btn:focus-visible,
    .nav-menu a:focus-visible,
    .btn:focus-visible,
    .back-to-top:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.55);
        outline-offset: 2px;
    }

    .portfolio-image {
        height: 210px;
    }

    .portfolio-content {
        padding: 1rem 1rem 1.2rem;
    }

    .portfolio-meta {
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }

    .portfolio-title {
        font-size: 1.18rem;
        margin-bottom: 0.65rem;
        line-height: 1.18;
    }

    .portfolio-description {
        font-size: 0.93rem;
        line-height: 1.68;
        -webkit-line-clamp: 3;
        margin-bottom: 1rem;
    }

    .portfolio-tag {
        padding: 0.32rem 0.7rem;
    }

    .modal-content {
        width: calc(100% - 0.75rem);
        margin: 0.375rem auto;
        max-height: calc(100svh - 0.75rem);
    }

    .modal-main-image {
        padding: 0.5rem 0.5rem;
    }

    .modal-media-arrow {
        display: none;
    }

    .modal-gallery-thumbs {
        padding: 0.5rem 0.5rem;
        gap: 0.4rem;
    }

    .modal-thumb-btn {
        width: 68px;
        height: 44px;
    }

    .modal-header,
    .modal-description,
    .modal-tags,
    .modal-videos,
    .modal-footer {
        padding-inline: 0.75rem !important;
    }

    .modal-title {
        font-size: 1.35rem;
    }

    .modal-nav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-gallery {
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto !important;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .reveal-on-scroll,
    .hero-orb,
    .timeline-item,
    .education-card,
    .portfolio-item,
    .portfolio-item *,
    .modal-content,
    .modal-content *,
    .navbar,
    .nav-menu,
    .nav-menu *,
    .btn,
    .filter-btn,
    .back-to-top {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }

    .particles-container,
    .mouse-trail-container {
        display: none !important;
    }
}

