/* ================================
   responsive.css
   All responsive rules live here
   ================================ */

/* Guard: avoid sideways scroll on small screens */
html,
body,
.window {
    overflow-x: hidden;
}

/* ---------- General tweaks ---------- */
@media (max-width: 1100px) {
    .buttons {
        gap: 6px;
    }

    .buttons button,
    .btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* ---------- Base helpers (safe for all sizes) ---------- */
.window {
    max-width: 1100px;
    width: min(1100px, 100%);
    /* was 92vw; using 100% avoids overflow with body padding */
    margin: 0 auto 24px;
    overflow: visible;
    /* avoid clipping flyouts */
}

.content img {
    max-width: 100%;
    height: auto;
    display: block;
}

.profile {
    display: grid;
    place-items: start;
}

.avatar {
    border-radius: 14px;
    padding: 10px;
}

.avatar img {
    display: block;
    width: clamp(140px, 38vw, 240px);
    height: auto;
    border-radius: 12px;
}

.avatar-social {
    margin-top: 10px;
    display: grid;
    grid-auto-flow: column;
    gap: 10px;
    list-style: none;
    padding: 0;
}

.avatar-social a {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
}

.about-me {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 20px;
    text-align: left;
}

.name {
    font-size: clamp(20px, 5.6vw, 34px);
    line-height: 1.15;
    letter-spacing: .02em;
}

.role {
    color: #7ef6a1;
    font-weight: 700;
    font-size: clamp(12px, 3.6vw, 16px);
}

.summary {
    max-width: 100ch;
    font-size: clamp(12px, 3.5vw, 15px);
    line-height: 1.6;
}

.details-grid {
    --gap: 8px;
    --cols: 2;
    display: grid;
    gap: var(--gap);
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    list-style: none;
    padding: 0;
    margin: 8px 0 0;
}

.details-grid .k {
    color: #9fb3c8;
    margin-right: 6px;
}

.details-grid .v a {
    text-decoration: underline;
}

.code-box {
    margin-top: 18px;
    border-radius: 12px;
    overflow: hidden;
}

.code-box .code {
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(11px, 3.2vw, 14px);
    line-height: 1.6;
    white-space: pre;
    /* keep code lines */
    overflow-x: auto;
    /* allow sideways scroll on small screens */
    -webkit-overflow-scrolling: touch;
}

/* ====================================
   Tablet/Phone stack (≤ 900px)
   ==================================== */
@media (max-width: 900px) {
    body {
        /* padding: 16px !important; */

        body {
            padding: clamp(12px, 4vw, 16px) !important;
        }
    }

    .content {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-areas: "profile" "about" "code" !important;
        gap: 16px !important;
        padding: 16px !important;
        justify-items: center !important;
        text-align: center !important;
    }

    .content .about-me {
        align-items: center !important;
        text-align: center !important;
        padding-right: 0 !important;
        margin: 0 auto !important;
        width: 100% !important;
        max-width: 90% !important;
    }

    .content .about-me .name {
        font-size: 22px !important;
    }

    .content .about-me .summary {
        margin: 0 auto !important;
        max-width: 90% !important;
    }

    /* details: force single column + center container, keep text left */
    .content .about-me .details-grid {
        grid-template-columns: 1fr !important;
        gap: 8px 12px !important;
        width: 90% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        text-align: left !important;
    }

    .avatar-glow img,
    .avatar img {
        max-width: 260px !important;
        width: 100% !important;
        height: auto !important;
    }

    .filename {
        display: none;
    }

    /* save space */
}

/* ====================================
   Narrow phones / iPhone SE (≤ 520px)
   ==================================== */
@media (max-width: 520px) {
    .title-bar {
        padding: 8px 10px;
    }

    .buttons {
        gap: 6px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .buttons button,
    .btn {
        padding: 6px 9px;
        font-size: 11px;
    }

    .content {
        justify-items: center;
        text-align: center;
    }

    .content .about-me {
        max-width: 90%;
    }

    .content .about-me .summary {
        max-width: 90%;
        font-size: 12.5px;
        line-height: 1.55;
        justify-content: center;
    }

    .content .about-me .details-grid {
        grid-template-columns: 1fr !important;
        gap: 6px 10px !important;
        width: 90% !important;
        margin: 0 auto !important;
        text-align: left !important;
    }

    .avatar-social a {
        width: 32px;
        height: 32px;
    }

    .code-box {
        padding: 12px 14px !important;
    }

    .code-box .code {
        font-size: 11px !important;
        line-height: 1.45 !important;
    }
}

/* ====================================
   Very narrow (≤ 380px)
   ==================================== */
@media (max-width: 380px) {
    .title-bar {
        padding: 8px 10px !important;
    }

    .filename {
        display: none !important;
    }

    .content .about-me {
        max-width: 94% !important;
    }

    .content .about-me .summary {
        max-width: 90% !important;
        font-size: 12px !important;
    }

    .content .about-me .details-grid {
        grid-template-columns: 1fr !important;
        gap: 6px 8px !important;
        width: 94% !important;
    }

    .code-box .code {
        font-size: 10.5px !important;
        line-height: 1.4 !important;
    }

    /* keep dropdown menu within viewport if it wraps */
    .tb-menu {
        max-width: calc(100vw - 24px) !important;
        right: 12px !important;
    }
}

/* ====================================
   Code readability on iOS/Android
   ==================================== */
.code-box .code,
pre,
code {
    -webkit-overflow-scrolling: touch;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    overflow-x: auto;
}


/* Keep code on one line but make it scrollable on phones */
@media (max-width: 520px) {
    pre#code.code {
        white-space: pre !important;
        /* single line */
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        font-size: 11px !important;
        line-height: 1.45 !important;
        max-width: 100% !important;
    }

    .code-box {
        padding: 12px 14px !important;
        overflow: hidden !important;
        /* keep rounded corners; scrolling stays on <pre> */
    }
}

@media (max-width: 380px) {
    pre#code.code {
        font-size: 10.5px !important;
        line-height: 1.4 !important;
    }
}