/* Phone adaptation of the existing cinematic desktop.
   DESIGN_VARIANCE 6 / MOTION_INTENSITY 5 / VISUAL_DENSITY 3.
   Native system type and existing artwork stay consistent with the desktop. */
.tb-profile-mobile-hint { display: none; }

@media (max-width: 768px), (max-width: 1024px) and (max-height: 500px) {
  :root {
    --tb-menubar-h: 48px;
    --phone-top: env(safe-area-inset-top, 0px);
    --phone-bottom: env(safe-area-inset-bottom, 0px);
    --phone-gutter: clamp(20px, 5.5vw, 32px);
  }
  html { height: auto; min-height: 100%; overflow-x: clip; overflow-y: auto; }
  body {
    box-sizing: border-box;
    height: auto;
    min-height: 100svh;
    overflow: visible;
    padding: calc(var(--phone-top) + 80px) 0 calc(var(--phone-bottom) + 166px);
    -webkit-text-size-adjust: 100%;
  }
  /* One legibility layer lets the film remain visible around the content. */
  #desktop::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(8,18,26,.58), rgba(8,18,26,.3) 60%, rgba(8,18,26,.52));
  }
  #desktop .tb-wall-credit {
    z-index: 1;
    left: max(var(--phone-gutter), env(safe-area-inset-left, 0px));
    right: max(var(--phone-gutter), env(safe-area-inset-right, 0px));
    bottom: calc(var(--phone-bottom) + 112px);
    width: fit-content;
    max-width: calc(100% - 2 * var(--phone-gutter));
    min-height: 24px;
    display: flex;
    align-items: center;
    font-size: 10px;
    line-height: 1.4;
    color: #e2e8eb;
    text-shadow: 0 1px 4px #000;
  }
  #menubar-root { height: calc(var(--tb-menubar-h) + var(--phone-top)); }
  .tb-menubar {
    --menubar-edge: max(var(--phone-gutter), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
    --menubar-apple-width: calc(15px * 393 / 471);
    box-sizing: border-box;
    height: 100%;
    padding: calc(var(--phone-top) + 2px) var(--menubar-edge) 2px;
    align-items: baseline;
    font-size: 13px;
    background: linear-gradient(180deg, rgba(10,20,28,.35), transparent);
  }
  /* Share the clock's text baseline with the bottom of the Apple artwork. */
  .tb-menubar-left,
  .tb-menubar-right { height: auto; align-items: baseline; }
  .tb-menubar-left { gap: 0; }
  .tb-menu-label { min-width: 44px; height: 44px; padding: 0; }
  .tb-menubar-left .tb-menu:first-child {
    height: auto;
    margin-left: calc((var(--menubar-apple-width) - 44px) / 2);
  }
  .tb-menubar-left .tb-menu:first-child > .tb-menu-label {
    position: relative;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
  }
  .tb-menubar-left .tb-menu:first-child > .tb-menu-label::before {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: inherit;
    background: rgba(230, 241, 248, .12);
    opacity: 0;
  }
  .tb-menubar-left .tb-menu.tb-open > .tb-menu-label::before { opacity: 1; }
  .tb-menubar-left .tb-menu-label > * { position: relative; }
  .tb-menubar-left .tb-menu:not(:first-child),
  .tb-cc-btn,
  #notch-root .tb-notch-collapsed,
  #promo-root .tb-promo-card--sticky { display: none; }
  .tb-clock-date { display: none; }
  .tb-clock-time { font-size: 12px; line-height: 15px; font-weight: 500; font-variant-numeric: tabular-nums; }
  .tb-dropdown {
    box-sizing: border-box;
    top: calc(100% + 8px);
    left: calc((44px - var(--menubar-apple-width)) / 2);
    width: min(220px, calc(100vw - 2 * var(--phone-gutter)));
    min-width: 0;
    max-height: calc(100dvh - var(--phone-top) - 80px);
    overflow-y: auto;
    padding: 6px;
    border: 1px solid rgba(210, 229, 240, .2);
    border-radius: 14px;
    background: rgba(15, 27, 36, .94);
    color: #f0f4f7;
    box-shadow: 0 12px 36px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .05);
    transform-origin: top left;
  }
  .tb-dropdown-item {
    box-sizing: border-box;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
  }
  .tb-dropdown-item:not(.tb-disabled):hover,
  .tb-dropdown-item:not(.tb-disabled):active { background: rgba(220, 236, 245, .1); }
  .tb-dropdown-sep { margin: 5px 12px; background: rgba(210, 229, 240, .16); }
  /* Keep the phone menu focused on the two personal information panels. */
  .tb-menu-desktop-only,
  .tb-dropdown-item.tb-disabled,
  .tb-dropdown-sep:has(+ .tb-disabled) { display: none; }
  #widgets-root { display: none; }
  #promo-root {
    position: relative;
    inset: auto;
    width: auto;
    z-index: 2;
    max-width: 520px;
    margin: 0 auto;
    padding: 0 var(--phone-gutter);
  }
  #promo-root .tb-promo { gap: 0; }
  #promo-root .tb-profile,
  #promo-root .tb-profile:hover,
  #promo-root .tb-profile.tb-liquid-ready {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    transform: none;
    transition: none;
  }
  #promo-root .tb-profile > .tb-liquid-canvas { display: none; }
  #promo-root .tb-profile-head { gap: 20px; padding: 0 2px; align-items: flex-start; }
  #promo-root .tb-avatar-frame,
  #promo-root .tb-profile-avatar { width: 72px; height: 72px; flex-basis: 72px; }
  #promo-root .tb-avatar-frame { margin-top: 4px; }
  #promo-root .tb-profile-name { font-size: clamp(30px, 8.8vw, 40px); line-height: 1.05; letter-spacing: -1.5px; }
  #promo-root .tb-profile-about { text-align: left; min-height: 64px; }
  #promo-root .tb-profile-mobile-hint {
    display: block;
    margin-top: 12px;
    color: #f4f7f8;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0;
  }
  #promo-root .tb-profile-mobile-hint::after { content: ' ↗'; padding-left: 4px; }
  #promo-root .tb-profile-website {
    box-sizing: border-box;
    min-height: 44px;
    margin-top: 0;
    padding-top: 4px;
    align-items: flex-start;
    font-size: 12px;
    color: #d1dbe1;
  }
  #promo-root .tb-profile-projects {
    /* Web glass approximation. Drawer: DESIGN_VARIANCE 3,
       MOTION_INTENSITY 4, VISUAL_DENSITY 4; symmetry and readable spacing. */
    box-sizing: border-box;
    margin-top: 24px;
    padding: 12px 18px 20px;
    border: 1px solid rgba(233,243,248,.2);
    border-radius: 24px;
    background: rgba(14,25,34,.86);
    -webkit-backdrop-filter: blur(18px) saturate(125%);
    backdrop-filter: blur(18px) saturate(125%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
    text-shadow: none;
  }
  #promo-root .tb-profile-projects--drawer {
    --projects-top: clamp(180px, 28svh, 300px);
    position: fixed;
    z-index: 48;
    top: calc(var(--phone-top) + var(--projects-top));
    left: max(var(--phone-gutter), env(safe-area-inset-left, 0px));
    right: max(var(--phone-gutter), env(safe-area-inset-right, 0px));
    width: auto;
    max-width: 440px;
    max-height: calc(100svh - var(--phone-top) - var(--phone-bottom) - var(--projects-top) - 132px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(0);
  }
  #promo-root .tb-profile-projects--drawer .tb-project-list {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #697c88 transparent;
  }
  #promo-root .tb-profile-projects--drawer[aria-hidden='true'] { pointer-events: none; }
  #promo-root .tb-projects-heading-row {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 44px minmax(0,1fr) 44px;
    align-items: center;
    flex-shrink: 0;
    gap: 4px;
    margin: 0 -6px 8px;
  }
  #promo-root .tb-profile-eyebrow {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    margin: 0;
    color: #f6f9fa;
    font-size: 20px;
    line-height: 26px;
    font-weight: 700;
    letter-spacing: -.35px;
    white-space: nowrap;
    text-align: center;
    text-transform: none;
  }
  #promo-root .tb-profile-projects-close {
    grid-column: 3;
    grid-row: 1;
    position: relative;
    isolation: isolate;
    z-index: 1;
    display: grid;
    place-items: center;
    align-self: center;
    justify-self: center;
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #e6eef2;
    line-height: 0;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  #promo-root .tb-profile-projects-close::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 6px;
    border-radius: inherit;
    background: rgba(225,239,247,.09);
  }
  #promo-root .tb-profile-projects-close:hover::before { background: rgba(225,239,247,.16); }
  #promo-root .tb-profile-projects-close:active { opacity: .7; }
  #promo-root .tb-profile-projects-close svg { display: block; width: 24px; height: 24px; }
  #promo-root .tb-profile-projects--drawer .tb-project-list { position: relative; z-index: 1; }
  #promo-root .tb-projects-reveal-sheen {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(115deg, transparent 28%, rgba(225,239,247,.12) 45%, rgba(225,239,247,.24) 50%, transparent 65%);
  }
  #promo-root .tb-profile-projects::selection,
  #promo-root .tb-profile-projects *::selection {
    background: #b8ceda;
    color: #14232e;
  }
  #promo-root .tb-projects-edge-tab {
    position: fixed;
    z-index: 55;
    top: 50%;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 116px;
    padding: 12px 8px;
    border: 1px solid rgba(233,243,248,.32);
    border-left: 0;
    border-radius: 0 16px 16px 0;
    background: rgba(18,31,43,.88);
    color: #f6f9fa;
    box-shadow: 8px 8px 24px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.18);
    -webkit-backdrop-filter: blur(18px) saturate(130%);
    backdrop-filter: blur(18px) saturate(130%);
    font: 650 10px/1 -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    letter-spacing: 1.6px;
    writing-mode: vertical-rl;
    text-transform: uppercase;
    translate: 0 -50%;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  #promo-root .tb-projects-edge-tab::after { content: '›'; margin-top: 8px; font: 18px/1 -apple-system, BlinkMacSystemFont, sans-serif; }
  #promo-root .tb-projects-edge-tab[hidden] { display: none; }
  #promo-root .tb-profile-projects-close:focus-visible,
  #promo-root .tb-projects-edge-tab:focus-visible { outline: 2px solid #d7ecfb; outline-offset: 3px; }
  #promo-root .tb-project { grid-template-columns: 18px minmax(0,1fr); column-gap: 12px; padding: 12px 0; }
  #promo-root .tb-project:first-child { padding-top: 4px; }
  #promo-root .tb-project:last-child { padding-bottom: 0; }
  #promo-root .tb-project + .tb-project { border-top-color: rgba(217,231,239,.14); }
  #promo-root .tb-project-copy { min-width: 0; }
  #promo-root .tb-project-link { grid-template-columns: 18px minmax(0,1fr) 20px; gap: 12px; min-height: 44px; }
  #promo-root .tb-project-number { padding-top: 4px; font-size: 10px; color: #a9bdcb; font-variant-numeric: tabular-nums; }
  #promo-root .tb-project-name { color: #f6f9fa; font-size: 19px; line-height: 24px; font-weight: 600; letter-spacing: -.3px; }
  #promo-root .tb-project-description { margin-top: 3px; font-size: 12px; line-height: 17px; color: #c6d3dc; }
  #promo-root .tb-project-arrow { align-self: center; margin-top: 0; color: #d3e1e9; }
  #promo-root :is(button,a):focus-visible { outline: 2px solid #d7ecfb; outline-offset: 5px; }
  #promo-root .tb-profile-about:active { opacity: .7; transform: translateY(1px); }
  #promo-root .tb-widget--visit { display: none; }

  .tb-dock-mobile .tb-dock-icon[href^='mailto:'],
  .tb-dock-mobile .tb-dock-icon[href^='https://wa.me'] { text-decoration: none; }

  /* Keep Spotify alive in the DOM when dismissed; only its trigger is hidden. */
  #notch-root { top: calc(var(--phone-top) + 56px); z-index: 45; }
  #notch-root .tb-notch { width: 0; height: 0; }
  #notch-root .tb-public-music .tb-spotify-panel {
    top: 0;
    width: min(460px, calc(100vw - 24px));
    transform: translateX(-50%);
  }
  #notch-root .tb-public-music .tb-spotify-surface {
    max-height: calc(100dvh - var(--phone-top) - var(--phone-bottom) - 128px);
    overflow-y: auto;
    border: 1px solid #ffffff20;
    border-radius: 24px;
  }
  #notch-root .tb-public-music .tb-spotify-header { padding: 12px 14px 12px 20px; gap: 10px; }
  #notch-root .tb-public-music .tb-spotify-close { width: 44px; height: 44px; }
  #notch-root .tb-public-music .tb-public-embed iframe { height: clamp(152px, calc(100dvh - 410px), 352px); }
  #notch-root .tb-public-music.compact .tb-public-embed iframe { height: 152px; }
  #notch-root .tb-public-music .tb-compact-toggle { display: none; }
  #notch-root .tb-public-music .tb-player-footer { padding: 12px 20px 18px; }
  #notch-root .tb-public-music .tb-spectrum-toggle,
  #notch-root .tb-public-music .tb-public-link,
  #notch-root .tb-public-music .tb-player-retry { min-height: 44px; }
  #notch-root .tb-public-music .tb-public-status { font-size: 11px; }
  #notch-root .tb-public-music .tb-player-footer-row { flex-wrap: wrap; }
  #notch-root .tb-public-music .tb-public-link { margin-left: auto; }

  .tb-about-me {
    width: calc(100% - 48px);
    max-width: 560px;
    max-height: calc((100dvh - var(--phone-top) - var(--phone-bottom) - 16px) * .7);
    border-radius: 0;
    box-shadow: 0 4px 18px rgb(17 25 24 / .2), 0 1px 4px rgb(17 25 24 / .12);
  }
  .tb-about-me-close { position: sticky; top: 12px; right: auto; width: 44px; height: 44px; margin: 12px 12px -56px auto; }
  .tb-about-me-page { display: flex; flex-direction: column; min-height: 0; padding: 21px 17px 0; }
  .tb-about-me-portrait { position: relative; width: min(100%, 340px); margin: 24px auto -28px; right: auto; bottom: auto; }
  .tb-about-me-greeting { padding-right: 40px; font-size: 28.8px; margin-bottom: 17px; }
  .tb-about-me-lead { font-size: 15.3px; line-height: 1.45; margin-bottom: 12px; }
  .tb-about-me-paragraph { font-size: 14.4px; line-height: 1.45; margin-bottom: 17px; }
  .tb-about-me-signature { font-size: 52.2px; margin: 17px 0; }
  .tb-about-me-actions { gap: 14px; }
  .tb-about-me-cta { font-size: 11.7px; }
  .tb-about-me-link { min-height: 44px; font-size: 12.6px; }

  #windows-root { top: calc(var(--phone-top) + var(--tb-menubar-h)); }
  .tb-window { min-width: 0; min-height: 0; }
  /* About has its own compact, centered geometry in apps.css. */
  .tb-window:not(.tb-window--web):not([data-app="about"]) {
    left: 8px !important;
    width: calc(100vw - 16px) !important;
    top: 8px !important;
    height: calc(100dvh - var(--phone-top) - var(--phone-bottom) - 166px) !important;
    max-height: calc(100dvh - var(--phone-top) - var(--phone-bottom) - 72px);
    border-radius: 20px;
  }
  .tb-window-titlebar { min-height: 48px; flex-basis: 48px; padding: 0 4px; touch-action: pan-y; }
  .tb-window-traffic { gap: 0; }
  .tb-tl { width: 44px; height: 44px; background: transparent; box-shadow: none; position: relative; }
  .tb-tl::before { content: ''; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #ff5f57; }
  .tb-tl-min::before { background: #febc2e; }
  .tb-tl-zoom::before { background: #28c840; }
  .tb-tl::after { position: relative; opacity: 1; font-size: 12px; }
  .tb-window-title { left: auto; right: 12px; transform: none; max-width: calc(100% - 152px); }
  .tb-webview-toolbar { gap: 0; padding: 4px 8px 8px; flex-wrap: wrap; }
  .tb-webview-toolbar button, .tb-webview-external { width: 44px; height: 44px; flex-basis: 44px; }
  .tb-webview-address { order: -1; flex: 1 0 100%; margin: 0; height: 44px; font-size: 16px; }
  .tb-webview-external { margin-left: auto; }
}

@media (max-width: 360px) {
  #promo-root .tb-profile-head { gap: 14px; }
  #promo-root .tb-avatar-frame, #promo-root .tb-profile-avatar { width: 60px; height: 60px; flex-basis: 60px; }
  #promo-root .tb-profile-projects { padding-left: 18px; padding-right: 18px; }
  #promo-root .tb-projects-heading-row { grid-template-columns: 36px minmax(0,1fr) 36px; gap: 0; }
  #notch-root .tb-public-music .tb-public-status { max-width: 100px; }
}
@media (max-width: 768px) and (min-height: 501px) and (max-height: 650px) {
  #promo-root .tb-profile-projects { padding-top: 8px; }
  #promo-root .tb-projects-heading-row { margin-bottom: 0; }
  #promo-root .tb-project { padding-top: 8px; padding-bottom: 8px; }
  #promo-root .tb-project:first-child { padding-top: 0; }
  #promo-root .tb-project:last-child { padding-bottom: 0; }
  #promo-root .tb-project-description { line-height: 16px; }
}
/* A single navigation row leaves room for the presentation in phone landscape. */
@media (min-width: 769px) and (max-width: 1024px) and (max-height: 500px) {
  .tb-about-me-greeting { font-size: 27px; }
  .tb-about-me-signature { font-size: 43.2px; }
}
@media (max-width: 1024px) and (max-height: 500px) {
  #promo-root .tb-profile-projects--drawer { --projects-top: 64px; }
  .tb-webview-toolbar { flex-wrap: nowrap; padding: 4px 8px; }
  .tb-webview-toolbar button:disabled { display: none; }
  .tb-webview-address { order: 0; width: 0; flex: 1 1 auto; }
}
@media (max-width: 768px) and (prefers-reduced-transparency: reduce), (max-width: 1024px) and (max-height: 500px) and (prefers-reduced-transparency: reduce) {
  #promo-root .tb-profile-projects { background: #172530; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (max-width: 768px) and (prefers-reduced-motion: no-preference), (max-width: 1024px) and (max-height: 500px) and (prefers-reduced-motion: no-preference) {
  html:not([data-glass-motion='off']) #promo-root .tb-profile-mobile-hint::after {
    display: inline-block;
    animation: phone-story-invite 850ms 1100ms ease-in-out 2;
  }
  @keyframes phone-story-invite {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(4px, -3px); }
  }
  #promo-root .tb-profile-head { animation: phone-arrive 600ms cubic-bezier(.2,.8,.2,1) both; }
  @keyframes phone-arrive { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
}
html[data-glass-motion="off"] #promo-root .tb-profile-head { animation: none; }
