/* =====================================================
   MOBILE / TABLET RESPONSIVE STYLES
   Extracted from style.css. Loaded for viewports <= 1000px.
   Desktop base styles remain in style.css.
   ===================================================== */

@media (max-width: 1000px) {
    .nav-shell {
        gap: 14px;
    }
    .nav-links {
        gap: 14px;
    }
    .nav-links a {
        font-size: 10px;
    }
    .brand-name {
        display: none;
    }
    .hero-grid {
        gap: 45px;
    }
}

@media (max-width: 780px) {
     :root {
        --gutter: 24px;
    }
    .nav-shell {
        min-height: 72px;
    }
    .brand-name {
        display: inline;
    }
    .menu-toggle {
        display: block;
        order: 3;
        flex-shrink: 0;
    }
    .nav-actions {
        margin-left: auto;
    }
    .nav-cta {
        display: none;
    }
    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0 var(--gutter);
        background: var(--bg);
        border-bottom: 1px solid var(--border);
        overflow: hidden;
        max-height: 0;
        opacity: 0;
        visibility: hidden;
        transition: max-height .4s ease, opacity .3s ease, padding .3s ease, visibility .3s ease;
    }
    .nav-links.is-open {
        max-height: 80vh;
        padding-block: 10px 20px;
        opacity: 1;
        visibility: visible;
    }
    .nav-links a {
        padding: 13px 0;
        border-bottom: 1px solid var(--border);
        font-size: 13px;
    }
    .nav-links a::after {
        display: none;
    }
    .hero {
        min-height: auto;
        padding-top: 65px;
    }
    .hero-grid {
        grid-template-columns: 1fr;
        gap: 55px;
    }
    .hero-title {
        font-size: clamp(54px, 12vw, 86px);
    }
    .hero-visual {
        width: min(78%, 370px);
    }
    .scroll-cue {
        margin-top: 50px;
    }
    .about-grid,
    .contact-inner {
        grid-template-columns: 1fr;
        gap: 35px;
    }
    .projects-heading {
        display: block;
    }
    .projects-heading .section-intro {
        margin-top: 20px;
    }
    .timeline-item {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

@media (max-width: 520px) {
     :root {
        --gutter: 20px;
    }
    .brand-mark {
        font-size: 25px;
    }
    .brand-name {
        font-size: 9px;
        letter-spacing: .1em;
    }
    .hero-title {
        font-size: clamp(48px, 13vw, 66px);
    }
    .hero-socials {
        gap: 16px;
    }
    .hero-visual {
        width: 84%;
    }
    .skills-grid,
    .projects-grid,
    .research-grid,
    .achievements-grid {
        grid-template-columns: 1fr;
    }
    .skill-card {
        min-height: auto;
    }
    .detail-row {
        font-size: 11px;
    }
    .footer-inner {
        align-items: flex-start;
    }
    .copyright {
        width: 100%;
    }
}

@media (max-width: 900px) {
    .site-header {
        top: 6px;
        width: calc(100% - 14px);
        margin-top: 6px;
        border-radius: 24px;
    }
    .nav-shell {
        min-height: 62px;
    }
    .achievements-grid-inner {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .site-header {
        border-radius: 20px;
    }
    .nav-links.is-open {
        border: 1px solid var(--border);
        border-radius: 22px;
        background: var(--surface);
        padding: 16px;
        box-shadow: var(--shadow);
    }
    .achievements-grid-inner {
        grid-template-columns: 1fr;
    }
    .certificate-modal {
        padding: 9px;
    }
    .certificate-dialog {
        padding: 12px;
        border-radius: 19px;
    }
    .certificate-stage {
        height: 65vh;
    }
}

@media (max-width: 900px) {
    .certificate-providers,
    .certificate-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .certificate-providers {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 11px;
    }
    .certificate-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
    .provider-card {
        padding: 17px;
        min-height: 165px;
        border-radius: 18px;
    }
    .provider-card strong {
        font-size: 15px;
    }
    .provider-description {
        font-size: 11px;
    }
    .certificate-content {
        padding: 13px;
    }
    .certificate-content h3 {
        font-size: 15px;
    }
    .certificate-footer {
        align-items: flex-start;
        flex-direction: column;
    }
    .certificate-open {
        width: 100%;
    }
}

@media (max-width: 360px) {
    .certificate-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 780px) {
    .menu-toggle {
        display: grid !important;
        place-items: center;
    }
    .nav-links {
        display: none;
    }
    .nav-links.is-open {
        display: flex;
    }
}

@media (max-width: 600px) {
    .certificate-modal {
        padding: 8px;
    }
    .certificate-dialog {
        width: 100%;
        max-height: 96dvh;
        padding: 13px;
        border-radius: 15px;
    }
    .certificate-modal-header {
        gap: 10px;
        padding-bottom: 13px;
    }
    .certificate-modal-header h2,
    #certificate-modal-title {
        font-size: 19px;
    }
    .certificate-close {
        width: 38px;
        height: 38px;
        font-size: 23px;
    }
    .certificate-stage {
        min-height: 220px;
        height: 72dvh;
        max-height: 72dvh;
        padding: 10px;
    }
    .certificate-watermark {
        font-size: 9px;
        letter-spacing: 1px;
    }
}

@media (max-width: 600px) {
    #certificate-modal {
        padding: 10px;
    }
    #certificate-modal .certificate-dialog {
        max-width: 96vw;
        max-height: 92vh;
        padding: 12px;
    }
    #certificate-modal #certificate-stage {
        max-height: 75vh;
    }
    #certificate-modal #certificate-stage img {
        max-height: 75vh;
    }
}

@media (max-width: 900px) {
    .contact-inner {
        grid-template-columns: 1fr;
        gap: 48px;
    }
    .contact-copy {
        max-width: 620px;
    }
    .contact-form {
        max-width: 100%;
        justify-self: stretch;
    }
}

@media (max-width: 600px) {
    .contact-section {
        padding: 75px 0 85px;
    }
    .contact-inner {
        width: calc(100% - 36px);
        gap: 38px;
    }
    .contact-copy h2 {
        font-size: clamp(43px, 12vw, 58px);
        letter-spacing: -2px;
    }
    .contact-form {
        padding: 23px 18px;
        gap: 19px;
        border-radius: 17px;
    }
    .contact-field {
        grid-template-columns: 1fr;
        gap: 9px;
    }
    .contact-field label {
        font-size: 12px;
    }
    .contact-field input {
        height: 48px;
    }
    .contact-field textarea {
        height: 125px;
        min-height: 125px;
    }
    .message-row label {
        padding-top: 0;
    }
    .contact-submit {
        width: 100%;
    }
    .contact-links {
        gap: 17px;
    }
}

@media (max-width: 820px) {
    .project-detail-layout {
        grid-template-columns: minmax(0, 1fr) 260px;
        gap: 25px;
    }
    .project-detail-aside {
        padding: 19px;
    }
}

@media (max-width: 680px) {
    .project-detail-shell {
        width: calc(100% - 36px);
        padding: 16px 0 58px;
    }
    .project-detail-hero {
        padding: 38px 0 27px;
    }
    .project-detail-hero h1 {
        font-size: clamp(36px, 10vw, 48px);
    }
    .project-detail-cover {
        margin-top: 25px;
        border-radius: 13px;
    }
    .project-detail-layout {
        grid-template-columns: 1fr;
        gap: 22px;
    }
    .project-detail-aside {
        position: static;
        order: -1;
        padding: 18px;
    }
    .project-detail-gallery {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .project-detail-gallery img {
        aspect-ratio: 16 / 10;
    }
}

@media (max-width: 680px) {
    .project-detail-gallery {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .project-detail-gallery-item {
        padding: 7px;
        border-radius: 16px;
    }
    .project-detail-gallery-item img {
        height: clamp(230px, 72vw, 340px);
        border-radius: 11px;
    }
    .project-detail-resources {
        margin-top: 28px;
    }
    .project-detail-links a {
        min-height: 54px;
        padding-inline: 12px;
    }
}

@media (max-width: 900px) {
    .contact-inner {
        grid-template-columns: 1fr;
        gap: 48px;
    }
    .contact-copy {
        max-width: 620px;
    }
    .contact-form {
        max-width: 100%;
        justify-self: stretch;
    }
}

@media (max-width: 600px) {
    .contact-section {
        padding: 75px 0 85px;
    }
    .contact-inner {
        width: calc(100% - 36px);
        gap: 38px;
    }
    .contact-copy h2 {
        font-size: clamp(43px, 12vw, 58px);
        letter-spacing: -2px;
    }
    .contact-form {
        padding: 23px 18px;
        gap: 19px;
        border-radius: 17px;
    }
    .contact-field {
        grid-template-columns: 1fr;
        gap: 9px;
    }
    .contact-field label {
        font-size: 12px;
    }
    .contact-field input {
        height: 48px;
    }
    .contact-field textarea {
        height: 125px;
        min-height: 125px;
    }
    .message-row label {
        padding-top: 0;
    }
    .contact-submit {
        width: 100%;
    }
    .contact-links {
        gap: 17px;
    }
}


/* =====================================================
   MOBILE LAYOUT + THEME ALIGNMENT FIXES
   ===================================================== */


/* =====================================================
   MOBILE LAYOUT + THEME ALIGNMENT FIXES
   Loaded after style.css; desktop styles remain unchanged.
   ===================================================== */

@media (max-width: 760px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: clip;
    }
    .section-wrap {
        width: min(100% - 36px, 620px);
        margin-left: auto;
        margin-right: auto;
    }
    .hero {
        min-height: auto;
        padding-top: 112px;
        padding-bottom: 58px;
    }
    .hero-grid {
        width: 100%;
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        gap: 38px;
        text-align: center;
    }
    .hero-copy,
    .hero-visual {
        width: 100%;
        max-width: 560px;
        margin-left: auto;
        margin-right: auto;
    }
    .hero-copy {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .hero-title,
    .hero-description,
    .hero-copy .eyebrow {
        text-align: center;
        margin-left: auto;
        margin-right: auto;
    }
    .hero-actions,
    .hero-socials {
        justify-content: center;
        flex-wrap: wrap;
    }
    .hero-visual {
        display: flex;
        justify-content: center;
    }
    .portrait-frame {
        width: min(100%, 390px);
        margin-left: auto;
        margin-right: auto;
    }
    .section-heading {
        width: 100%;
        text-align: center;
        margin-left: auto;
        margin-right: auto;
    }
    .section-heading>*,
    .section-intro {
        margin-left: auto;
        margin-right: auto;
    }
    .about-grid,
    .skills-grid,
    .projects-grid,
    .timeline,
    .research-grid,
    .certificate-grid,
    .certificate-providers {
        width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
    .about-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .project-card,
    .skill-card,
    .experience-card,
    .research-card,
    .achievement-card {
        width: 100%;
        min-width: 0;
        margin-left: auto;
        margin-right: auto;
    }
    .filter-row {
        justify-content: center;
        flex-wrap: wrap;
    }
    .contact-inner {
        width: min(100% - 36px, 620px);
        margin-left: auto;
        margin-right: auto;
    }
    /* Project detail view must use the full viewport and stay centered. */
    #project-detail-view {
        width: 100%;
        max-width: 100vw;
        left: 0;
        right: 0;
        padding-left: 0;
        padding-right: 0;
    }
    .project-detail-shell {
        width: min(100% - 36px, 620px);
        margin-left: auto;
        margin-right: auto;
        padding-top: max(16px, env(safe-area-inset-top));
        padding-bottom: max(40px, env(safe-area-inset-bottom));
    }
    .project-detail-back {
        min-height: 44px;
        max-width: 100%;
    }
    .project-detail-hero,
    .project-detail-main,
    .project-detail-gallery-section,
    .project-detail-resources {
        width: 100%;
        max-width: 100%;
        margin-left: auto;
        margin-right: auto;
    }
    .project-detail-hero h1,
    .project-detail-hero .project-detail-lead {
        text-align: center;
        margin-left: auto;
        margin-right: auto;
    }
    .project-detail-gallery {
        grid-template-columns: minmax(0, 1fr);
    }
    .project-detail-gallery-item {
        width: 100%;
        min-width: 0;
        margin-left: auto;
        margin-right: auto;
    }
    .project-detail-gallery-item img {
        width: 100%;
        height: auto;
        max-width: 100%;
        object-fit: contain;
    }
    .project-detail-links {
        width: 100%;
    }
    .certificate-dialog {
        width: calc(100% - 24px);
        max-width: 620px;
        margin-left: auto;
        margin-right: auto;
    }
}


/* Keep theme variables and theme class synchronized visually. */

:root[data-theme="light"],
body.light-theme {
    color-scheme: light;
}

:root[data-theme="dark"] {
    color-scheme: dark;
}

@media (max-width: 380px) {
    .section-wrap,
    .project-detail-shell,
    .contact-inner {
        width: calc(100% - 28px);
    }
    .hero-actions .button {
        max-width: 100%;
    }
    .project-detail-hero h1 {
        overflow-wrap: anywhere;
    }
}