/* ─────────────────────────────────────────────────────────────
   MOBILE — phone-native overrides for index.html + project.html
   Loaded AFTER style.css and the per-page inline <style> so it wins
   on equal specificity. Activates ≤768px (phones, small tablets
   in portrait). Goal: compact, easy to read, made-for-the-phone.

   Sections:
     1. Global / chrome
     2. Hero (index)
     3. Timeline (index)
     4. Projects (index)
     5. Skills + footer (index)
     6. Project detail page (project.html)
     7. Tiny phones (≤400px)
   ───────────────────────────────────────────────────────────── */

/* Mobile-only elements — hidden everywhere above 768px */
.m-idline, .m-actions { display: none; }

@media (max-width: 768px) {

  /* ═══════════ 1 · GLOBAL / CHROME ═══════════ */

  /* Static, battery-friendly background: kill the fixed-attachment
     repaint jank that plagues mobile Safari/Chrome. The SVG brush
     pattern stays, just scrolls with the page. */
  body {
    background-attachment: scroll;
  }

  /* Tighter rhythm overall — less air, more content per screen */
  .section {
    padding: 34px var(--gutter) 38px;
  }
  .section--hero { padding-top: 20px; }
  .section + .section { border-top: 1px solid var(--rule); }

  .section-title { font-size: clamp(38px, 11vw, 56px); margin-bottom: 16px; }
  .section-lede  { font-size: 15.5px; line-height: 1.5; }
  .section-grid  { gap: 28px 0; }

  /* Header: the brand is replaced by the same pill "slider" nav used
     on desktop, with the theme toggle kept on the right. No bottom bar. */
  .brand { display: none; }
  .site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: auto;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  /* Restore the desktop pill look (style.css's ≤768 rules strip it) */
  .site-nav {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: space-between;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 2px;
    padding: 4px;
    border: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    border-radius: 999px;
    background: var(--bg-2);
  }
  .site-nav::-webkit-scrollbar { display: none; }
  .nav-link {
    flex: 0 0 auto;
    padding: 7px 11px;
    font-size: 12.5px;
    gap: 4px;
    min-height: 32px;
    align-items: center;
  }
  .nav-idx { font-size: 8.5px; }
  .theme-toggle { flex: 0 0 auto; }


  /* ═══════════ 2 · HERO ═══════════ */

  /* Identity-first layout. Explicit grid rows:
       1 · name (left) + portrait (right)
       2 · location + availability line
       3 · topic chips
       4 · bio
       5 · quick actions (email / linkedin / github + CV)
     Both wrapper columns are display:contents so every hero element
     is placed directly on this grid. */
  .hv2-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 18px;
    row-gap: 18px;
    align-items: center;
  }
  .hv2-left,
  .hv2-right { display: contents; }

  .hero-name           { grid-row: 1; grid-column: 1; align-self: center; min-width: 0; }
  .hv2-right .portrait { grid-row: 1; grid-column: 2; }
  .m-idline            { grid-row: 2; grid-column: 1 / -1; }
  .hv2-topics          { grid-row: 3; grid-column: 1 / -1; }
  .hv2-bio             { grid-row: 4; grid-column: 1 / -1; }
  .m-actions           { grid-row: 5; grid-column: 1 / -1; }

  /* Desktop-only hero pieces replaced by the mobile components */
  .hv2-contacts { display: none; }
  .hero-status  { display: none; }
  .cv-cta       { display: none; }

  /* Name — reduced so it fits beside the photo on a phone */
  .hero-name {
    font-size: clamp(28px, 8.5vw, 44px);
    line-height: .94;
    margin: 0;
  }

  /* Photo — compact card on the right of the header */
  .hv2-right .portrait { width: clamp(110px, 34vw, 140px); margin: 0; }
  .hv2-right .portrait-frame {
    aspect-ratio: 4 / 5;
    max-height: none;
    border-radius: 14px;
  }
  .hv2-right .portrait-placeholder { border-radius: 14px; }
  .hv2-right .portrait-initials { font-size: 52px; }

  /* Identity line — location + availability, one glanceable row */
  .m-idline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
  }
  .m-loc,
  .m-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: .06em;
    color: var(--fg-muted);
    white-space: nowrap;
  }
  .m-loc svg { color: var(--fg-dim); flex-shrink: 0; }
  .m-status { color: var(--accent); }

  /* Topics — compact, left-aligned under the header */
  .hv2-topics { gap: 7px; justify-content: flex-start; }
  .hv2-topic  { padding: 6px 13px; font-size: 12px; }

  /* Bio — slightly tighter, full readable width */
  .hv2-bio { font-size: 15px; line-height: 1.6; max-width: none; text-align: left; }

  /* Quick actions — three equal contact tiles + full-width CV button.
     Every target is ≥56px tall. */
  .m-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  .m-act {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 68px;
    padding: 10px 6px;
    border: 1px solid var(--rule-2);
    border-radius: 14px;
    background: color-mix(in oklab, var(--bg-2) 75%, transparent);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .15s var(--ease), border-color .2s var(--ease);
  }
  .m-act:active { transform: scale(.96); }
  .m-act-icon {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border-radius: 7px;
    overflow: hidden;
  }
  .m-act-icon svg { display: block; }
  .m-act-icon--mail { color: var(--fg-muted); }
  .m-act-label {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .01em;
    color: var(--fg-muted);
  }
  .m-act--cv {
    grid-column: 1 / -1;
    flex-direction: row;
    gap: 10px;
    min-height: 56px;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 12px 28px -14px color-mix(in oklab, var(--accent) 60%, transparent);
  }
  .m-act--cv .m-act-label {
    color: var(--accent-ink);
    font-size: 14.5px;
    font-weight: 600;
  }
  .m-act--cv .m-act-arrow {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border-radius: 50%;
    border: 1px solid color-mix(in oklab, var(--accent-ink) 45%, transparent);
    color: var(--accent-ink);
    font-size: 14px;
  }


  /* ═══════════ 3 · TIMELINE ═══════════ */

  /* Single left rail, compact cards, guaranteed no sideways overflow */
  .timeline { margin-top: 28px; }
  .timeline::before { left: 15px; }

  .tl-item {
    grid-template-columns: 34px 1fr;
    padding: 9px 0;
  }
  .tl-item + .tl-item { margin-top: 6px; }

  .tl-marker { padding-top: 6px; }
  .tl-marker-dot { width: 24px; height: 24px; font-size: 11px; }
  .tl-marker::before { top: 17.5px; }
  .tl-item[data-side="left"]  .tl-marker::before,
  .tl-item[data-side="right"] .tl-marker::before { left: 100%; right: auto; width: 11px; }

  .tl-item[data-side="left"]  .tl-body,
  .tl-item[data-side="right"] .tl-body { padding-left: 12px; padding-right: 0; }

  /* Card: shrinkable, never wider than its column */
  .tl-card { max-width: none; min-width: 0; border-radius: 12px; position: relative; }
  .tl-card-content { padding: 12px 14px 11px; gap: 3px; min-width: 0; }
  .tl-card-logo {
    flex: 0 0 58px;
    min-height: 0;
    padding: 10px 8px;
  }
  .tl-card-logo img { max-width: 42px; max-height: 40px; }
  .tl-card-title { font-size: 15px; line-height: 1.22; }
  .tl-card-date  { font-size: 9.5px; }
  .tl-card-badge { font-size: 8.5px; padding: 2px 7px; }
  .tl-card-org,
  .tl-card-loc   { font-size: 9.5px; }
  /* Drop the "click for more details →" line on mobile — the whole
     card is tappable; a small chevron signals it instead */
  .tl-card-cta { display: none; }
  .tl-card::after {
    content: "›";
    position: absolute;
    top: 50%;
    right: 11px;
    transform: translateY(-55%);
    font-size: 18px;
    line-height: 1;
    color: var(--fg-dim);
    pointer-events: none;
  }
  .tl-card-content { padding-right: 26px; }


  /* ═══════════ 4 · PROJECTS ═══════════ */

  /* Featured: same compact row format as the other project cards,
     but marked as special — yellow border + the orange ★ Featured badge.
     The desktop "click me" arrow is removed (it overlapped the filter
     chips on small screens). */
  .featured-grid { margin-top: 28px; gap: 12px; }

  .feat-card-wrap { overflow: visible; }
  .proj-hint { display: none; }
  .section--projects.has-proj-hint .proj-grid { padding-top: 0; }

  .feat-card {
    grid-template-columns: 112px 1fr;
    align-items: stretch;
    border: 1.5px solid #f0c040;
    border-left-width: 1.5px;
    border-radius: 12px;
    box-shadow: 0 10px 26px -16px rgba(240, 192, 64, .45);
  }
  .feat-card:hover { transform: none; border-color: #f0c040; }

  .feat-thumb {
    min-height: 100px;
    height: 100%;
    border-right: 1px solid var(--rule);
  }

  .feat-body {
    padding: 12px 14px;
    gap: 5px;
    align-content: center;
    justify-content: center;
  }
  .feat-top { gap: 8px; }
  .feat-badge {
    font-size: 9.5px;
    letter-spacing: .12em;
    padding: 3px 9px;
  }
  .feat-type { display: none; }
  .feat-name { font-size: 18px; line-height: 1.15; }
  .feat-desc {
    font-size: 12.5px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .feat-foot { display: none; }

  /* Non-featured: compact horizontal rows — thumbnail left, title right.
     Hide the heavy footer link bar + overlay meta; the whole row opens
     the project page, where the links live. */
  .proj-grid,
  .proj-overflow { gap: 12px; margin-top: 28px; }

  .proj-card {
    display: grid;
    grid-template-columns: 112px 1fr;
    grid-template-rows: auto;
    align-items: stretch;
    border-radius: 12px;
  }
  .proj-card .proj-thumb {
    aspect-ratio: auto;
    height: 100%;
    min-height: 100px;
    border-bottom: none;
    border-right: 1px solid var(--rule);
  }
  .proj-meta-top { display: none; }
  .proj-thumb-label {
    font-size: 8.5px;
    letter-spacing: .08em;
    padding: 3px 6px;
    text-align: center;
    max-width: 90%;
  }
  .proj-body {
    padding: 12px 14px;
    gap: 5px;
    align-content: center;
  }
  .proj-name { font-size: 18px; line-height: 1.15; }
  .proj-desc {
    font-size: 12.5px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .proj-stack,
  .proj-foot { display: none; }

  /* "View all" button — a touch smaller */
  .proj-view-all-wrap { margin-top: 20px; }


  /* ═══════════ 5 · SKILLS + FOOTER ═══════════ */

  .skills-grid { margin-top: 32px; gap: 26px; }
  .skill-cat { padding-top: 18px; gap: 14px; }
  .skill-cat-title { font-size: 24px; }

  .site-footer { margin-top: 40px; }
  .footer-rule { margin-bottom: 36px; }
  .foot-name { font-size: 30px; }


  /* ═══════════ 5c · EVENT MODAL → BOTTOM SHEET ═══════════ */

  .modal {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }
  .modal-shell {
    width: 100%;
    max-width: none;
    max-height: 86dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    padding: 34px 22px calc(28px + env(safe-area-inset-bottom));
    transform: translateY(60px);
  }
  .modal.is-open .modal-shell { transform: none; }
  /* Drag-handle affordance */
  .modal-shell::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: var(--rule-2);
  }
  .modal-close {
    width: 40px; height: 40px;
    top: 14px; right: 14px;
  }


  /* ═══════════ 6 · PROJECT DETAIL (project.html) ═══════════ */

  /* Wide tables shouldn't clip — let them scroll horizontally */
  .blog-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .blog-table { min-width: 480px; }

  /* Slightly shorter cover so content is reachable sooner */
  .proj-hero { min-height: clamp(300px, 52vh, 460px); }
  .proj-article { padding: 32px var(--gutter); }
}


/* ═══════════ 7 · TINY PHONES (≤400px) ═══════════ */
@media (max-width: 430px) {
  /* Drop the index numbers so all four tabs fit without scrolling */
  .nav-idx { display: none; }
  .nav-link { padding: 7px 10px; font-size: 12px; }
}

@media (max-width: 400px) {
  /* Keep name smaller so it fits beside the portrait on tiny phones */
  .hero-name { font-size: clamp(24px, 8vw, 38px); }
  .hv2-right .portrait { width: clamp(96px, 30vw, 124px); }

  /* Even tighter project rows */
  .proj-card { grid-template-columns: 96px 1fr; }
  .proj-card .proj-thumb { min-height: 92px; }
  .proj-name { font-size: 16.5px; }

  .tl-card-logo { flex: 0 0 52px; }
  .tl-card-title { font-size: 14px; }
}
