/* ============================================================================
   mobile.css — the phone site.

   CJ, 2026-08-18: "all pages on PC not to change ... but we seriously need to
   optimise the mobile side ... same look and feel as Instagram, Facebook,
   SoundCloud, YouTube Music."

   Every rule in this file lives inside a max-width media query, and this file
   is loaded last. That is deliberate and it is the whole architecture: the
   desktop site cannot be changed from here, by me or by anyone after me, so
   the promise "the PC site does not move" is enforced by the file rather than
   remembered. scripts/desktop-guard.mjs measures 24 desktop page layouts before
   and after and proves it.

   What actually separates an app-feeling phone site from a shrunk desktop one,
   in the order it matters:

     1. Navigation that is always visible and under the thumb, not folded into
        a hamburger. Five tabs, labelled, permanent.
     2. Chrome that gets out of the way. A 78px header with a 212px logo is a
        desktop header; a phone gives that space to content.
     3. Content that uses the full width. 24px of gutter plus 20px of card
        padding on a 390px screen leaves 302px for the thing you came to read.
     4. Type big enough to read at arm's length, and targets big enough to hit.
     5. Respect for the hardware: the notch, the home indicator, and the fact
        that iOS zooms any field under 16px and never zooms back.
   ============================================================================ */

/* The one rule in this file outside a media query, and it has to be: the tab
   bar is built into every page's DOM by js/ws-app.js, so without this it would
   render as a list of links at the bottom of the desktop site. Hiding it here
   rather than in a shared stylesheet keeps everything about the phone site in
   one place — and it can only ever remove a mobile-only element from desktop,
   never change desktop's own layout. desktop-guard.mjs caught it appearing on
   15 pages before this line existed. */
.tabbar { display: none; }

@media (max-width: 820px) {

  :root {
    --tabbar-h: 58px;
    /* A phone header carries a logo and one action. Nothing else fits, and
       nothing else earns the height. */
    --header-h: 56px;
  }

  /* ---------------------------------------------------------------- the tabs
     The one change that does most of the work. Instagram, SoundCloud and
     YouTube Music all put their destinations here for the same reason: the
     bottom third of a phone is the only part a thumb reaches without the hand
     moving, and a permanent bar answers "where am I" and "what else is there"
     without a tap.

     Built by js/ws-app.js from the same list the desktop nav uses. */
  .tabbar {
    display: grid;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1200;                       /* above the mini player's 1000 */
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg-deepest) 88%, transparent);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-top: 1px solid var(--border-subtle);
  }
  /* Without blur, 88% opacity is just murky. Go solid instead. */
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .tabbar { background: var(--bg-deepest); }
  }
  .tabbar__tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    text-decoration: none;
    color: var(--text-muted);
    -webkit-tap-highlight-color: transparent;
    transition: color .14s ease;
  }
  .tabbar__tab svg { width: 23px; height: 23px; }
  .tabbar__tab span {
    font-family: var(--f-body);
    white-space: nowrap;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1;
  }
  .tabbar__tab.is-on { color: var(--teal-primary); }
  .tabbar__tab:active { color: var(--text-primary); }
  /* The unread badge ws-app.js hangs on any link to messages.html. */
  .tabbar__tab .nav-badge {
    position: absolute;
    transform: translate(13px, -12px);
  }

  /* Room to scroll past the bar, and past the home indicator under it. */
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

  /* The site-wide player bar rides above the tabs rather than under them, the
     stack every music app uses. Before 2026-10-02 the dock sat at bottom: 0
     under the tab bar (z-index 1200), so on a phone it was hidden behind them. */
  body:has(.tabbar) .wsbar {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: 10px;
  }
  body:has(.tabbar):has(.wsbar:not([hidden])) {
    /* --wsbar-h is the bar's real height (ws-player.js): 96px since the song's line joined the strip. */
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--wsbar-h, 96px));
  }

  /* The video panel sits above both: the bar when it is showing, the tabs always. */
  body:has(.tabbar) .wsvideo {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px);
  }
  body:has(.tabbar):has(.wsbar:not([hidden])) .wsvideo {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--wsbar-h, 96px));
  }

  /* -------------------------------------------------------------- the header
     56px instead of 78, and a logo sized for a phone. The tabs are the page
     list here, so the header is the logo, search, and you (or LOG IN). */
  .site-header { height: var(--header-h); }
  .nav-container { height: var(--header-h); gap: 10px; padding-inline: 14px; }
  .logo-img { height: 40px; }
  .site-header .nav-main { display: none; }
  .site-header .site-search-btn { margin-left: auto; }
  .nav-actions { gap: 8px; }
  .nav-actions .btn { padding: 8px 13px; font-size: 12px; }

  /* --------------------------------------------------------------- the width
     24px of page gutter and 20px of card padding spends 88px of a 390px screen
     on nothing. 14 and 14 leaves the content 50px more room, which on a phone
     is the difference between two words on a line and three. */
  .page-wrap { padding: 0 14px calc(28px + var(--tabbar-h)); }
  .page-band { padding: 18px 16px 14px; }
  .panel { padding: 14px; }
  .panel + .panel { margin-top: 12px; }
  .layout { gap: 16px; margin-top: 16px; }

  /* The composer cannot fit tools, a counter and Post on one line at this
     width, so it takes two on purpose: what you can add on the left, what you
     do with it on the right. Wrapping without deciding where left "Post"
     stranded at the far left of its own line, which reads like a mistake. */
  .composer-box__actions { justify-content: flex-end; }
  .composer-box__tools { margin-right: auto; }
  .composer-box__actions .composer-count { margin-left: 0; }

  /* The profile header's three buttons sit in one row that cannot shrink, and
     as a grid item that row set the column's minimum width: 415px of content
     inside a 362px page. Chrome answers that by widening the layout viewport
     rather than scrolling, so the whole account page rendered zoomed out at
     437px — every measurement said "fits" while a person saw shrunken text and
     a cut-off "Edit profile". Let the row wrap and the column can be narrow. */
  .profile-head { grid-template-columns: minmax(0, 1fr); }
  .profile-head__actions { flex-wrap: wrap; }
  .profile-head__info { min-width: 0; }

  /* The band is a title, not a landing page. Two lines and a sentence. */
  .page-band__title { font-size: clamp(26px, 8vw, 34px); line-height: 1.08; }
  .page-band__eyebrow { font-size: 10px; }
  .page-band__sub { font-size: 14.5px; line-height: 1.45; margin-top: 8px; }

  /* Four tabs at desktop padding measure 494px and scroll out of sight with no
     hint that they do. Tightened, they all fit inside 362px and the page stops
     hiding a quarter of itself. */
  .tabs { margin-inline: 0; }
  .tab { padding: 12px 10px; font-size: 13.5px; letter-spacing: 0.01em; }

  /* Signing up is the first thing a new person does, and on a phone it should
     start under the header rather than floating in the middle of a screen it
     is taller than anyway. 48px of lead-in becomes 20px, and the form is
     visible without a scroll. */
  .auth-wrap {
    place-items: start center;
    padding: calc(var(--header-h) + 20px) 14px 40px;
    min-height: 0;
  }
  .auth-card { padding: 22px 18px; }

  /* ----------------------------------------------------------------- reading
     16px is the floor for body copy on a phone, and the floor for any field:
     iOS Safari zooms the page on focus below it and does not zoom back. */
  .post__body, .dm-msg__text { font-size: 16px; line-height: 1.55; }
  input, select, textarea { font-size: 16px; }

  /* -------------------------------------------------------------- messages
     A chat is the one screen that should not scroll the page at all: the inbox
     or the conversation fills the space between the header and the tabs, and
     scrolls inside itself.

     dvh, not vh. On iOS Safari 100vh is the height the page WOULD have with
     the URL bar hidden, so a pane sized in vh puts its last message and the box
     you type into underneath the browser's own chrome. It is the single most
     common way a mobile chat feels broken, and dvh is the fix. The vh line
     stays first as the fallback for anything that has not caught up. */
  .dm {
    /* --wsbar-h: the player bar's height while it shows (ws-player.js), so the
       message box is never underneath it (2026-10-03). */
    height: calc(100vh - var(--header-h) - var(--tabbar-h) - var(--wsbar-h, 0px));
    height: calc(100dvh - var(--header-h) - var(--tabbar-h) - env(safe-area-inset-bottom) - var(--wsbar-h, 0px));
    min-height: 0;
  }

  /* The pane could not be narrower than its own contents. `1fr` floors at
     min-content, and the thread's header row — back, avatar, name, Mute, Leave,
     Block — refuses to shrink, so the pane laid out at about 520px inside a
     390px phone and `.dm { overflow: hidden }` quietly cut the rest off. Every
     message ran off the right edge mid-sentence and the Send button was a
     sliver: CJ, 2026-08-18, "on the messaging page on cell you can't see
     everything." minmax(0,1fr) lets the column be as narrow as the screen, and
     min-width:0 lets the panes inside it agree. */
  .dm { grid-template-columns: minmax(0, 1fr); }
  .dm-list, .dm-thread { min-width: 0; }
  .dm-thread__head { padding: 10px 12px; gap: 10px; }
  .dm-thread__tools { flex-shrink: 0; gap: 4px; }
  .dm-thread__tools .btn-sm { padding: 8px 9px; font-size: 12px; }
  .dm-compose { min-width: 0; }
  .dm-compose textarea { min-width: 0; }
  .dm-compose .btn { flex-shrink: 0; padding: 10px 16px; }

  /* A chat screen is the whole screen. The site footer sitting under a
     fixed-height pane made the page 1547px tall — 700px of legal links below a
     conversation, and a page that slid around under the thumb while trying to
     scroll the messages. No app does that. */
  body.page-dm { padding-bottom: 0; overflow: hidden; }
  body.page-dm .site-footer { display: none; }

  /* The placeholder is longer than the field and the button cannot shrink, so
     "Search artists, track:" is all anyone reads. Let the field own the row. */
  .search-bar { gap: 8px; }
  .search-input { min-width: 0; }
  .search-input::placeholder { font-size: 15px; }

  /* ---------------------------------------------------------- post actions
     Like, Comment and Share are flex items that shrink, and their labels were
     allowed to break, so at 360px — which is what most Android phones report —
     the row squeezed them until the words snapped in half: "Lik / e",
     "Comme / nt", "Shar / e". Measured on the live site at 360px, each button
     was 56px tall because every label had gone to two lines.

     A label never breaks now; if the row runs out of room a whole button drops
     to the next line instead, which is legible at any font size the reader has
     set. Tighter padding means it does not have to. */
  .post__actions { flex-wrap: wrap; gap: 4px; row-gap: 4px; }
  .post-action {
    flex: 0 0 auto;
    white-space: nowrap;
    gap: 6px;
    padding: 9px 8px;
  }

  /* The pencil and the bin on your own posts are 32px squares. Same treatment
     as the play buttons: the drawing stays, the area that answers a tap grows
     to 44px past it. Two destructive-ish controls 4px apart is how a thumb
     deletes the wrong thing. */
  .post__edit, .post__delete { position: relative; }
  .post__edit::after, .post__delete::after { content: ""; position: absolute; inset: -6px; }
  .post__owner-actions { gap: 10px; }
  /* The "add a reaction" smiley, same again — 28px drawn, 44px to hit. */
  .reaction-add { position: relative; }
  .reaction-add::after { content: ""; position: absolute; inset: -8px; }

  /* ------------------------------------------------------------- link cards
     The card is as wide as the picture it previews — a portrait gig poster
     makes a 240px card — and inside that, a 107px platform chip beside the
     title left the title 85px and three lines to say "Jazzcatz Capetown on
     Reels" in. The title is the point of a preview, so it gets the width and
     the source sits under it. */
  .embed-card__body,
  .embed-card--link .embed-card__body {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .embed-card__meta,
  .embed-card--link .embed-card__meta { flex: none; width: 100%; }
  .embed-plat,
  .embed-card--link .embed-plat { margin-left: 0; }

  /* ------------------------------------------------------------ side-scrolls
     A row that scrolls sideways should stop where a card starts, not halfway
     through one. Snap makes a drag feel decided instead of loose. */
  .artist-row, .video-grid, .studio-row, .ev-scroller {
    scroll-snap-type: x mandatory;
    scroll-padding-left: 14px;
    -webkit-overflow-scrolling: touch;
  }
  .artist-row > *, .studio-row > * { scroll-snap-align: start; }
}

/* ------------------------------------------------------------- edge to edge
   Below 560px the feed is the page, so it gets all of it: the cards lose their
   side borders and corners and run to both edges, with a hairline between them.
   This is what a phone feed looks like everywhere it is done well, and it buys
   back the last 28px of line length. Panels that are lists rather than reading
   keep their card shape so the page still has structure. */
@media (max-width: 560px) {
  .col-center > .panel,
  #feed > .panel,
  #feedEmpty {
    margin-left: -14px;
    margin-right: -14px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    padding-left: 16px;
    padding-right: 16px;
  }
  #feed > .panel + .panel { margin-top: 8px; }
}

/* ===========================================================
   THE CLIENT'S PHONE ORDER                   (added 2026-08-27)
   -----------------------------------------------------------
   His portrait sketch runs: title, search, TOP FEATURED ARTIST,
   FEATURED ARTISTS, TOP SONGS, VIDEOS, TOP STUDIO/PRODUCER.

   His landscape sketch pairs the two spotlights side by side at
   the top. So the two layouts genuinely disagree about where the
   studio block goes, and this is the half that moves it down.

   display:contents dissolves the desktop pairing wrapper so both
   spotlight sections become direct children of <main> and can be
   ordered independently. Everything is inside the media query -
   the desktop pairing cannot be reached from here.
   =========================================================== */
@media (max-width: 820px) {
  body.page-home main#main { display: flex; flex-direction: column; }

  /* Two separate things go wrong the moment main becomes a flex column, and
     both were measured on a 390px viewport before these lines existed.
     
     1. Every section in the container rule carries margin-left/right: auto.
        On the cross axis of a flex container an auto margin SUPPRESSES
        stretch, so the sections stopped filling the page and sized to their
        own content instead - 386px, 157px, 343px and 242px in one column.
        The centring those margins do is dead weight here anyway: the viewport
        is far below --container.
        
     2. A flex item's min-width is auto, so the section holding the artist row
        (a horizontal scroller below 1200px) reported its 1140px of content as
        its minimum and stretched the page to 1050px rather than scrolling
        inside itself. */
  body.page-home main#main > * {
    width: 100%;
    min-width: 0;
    margin-left: 0;
    margin-right: 0;
  }

  /* The wrapper stops existing as a box; its two sections become
     siblings of everything else in main. */
  .spotlight-pair { display: contents; }

  /* Explicit, because once one child is ordered the implicit
     document order stops being a reliable description of the page. */
  body.page-home #hero             { order: 1; }
  body.page-home #browse           { order: 2; }
  body.page-home #artists          { order: 3; }
  body.page-home #featured-artists { order: 4; }
  body.page-home #songs            { order: 5; }
  body.page-home #videos           { order: 6; }
  body.page-home #studios          { order: 7; }
  body.page-home #studio-producers { order: 8; }
  body.page-home #placements       { order: 9; }

  /* Each spotlight section carries its own gutters now that the
     wrapper that held them is gone. */
  .spot-section {
    padding-left: var(--pad-x);
    padding-right: var(--pad-x);
    padding-top: 34px;
  }
  .spotlight-pair { padding-top: 0; }

  .songs-section, .videos-section, .sp-section { padding-top: 34px; }

  /* He drew two video columns on the phone; the desktop rule opens
     to three, which must not leak down here. */
  .video-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  .spotlight__name { font-size: clamp(19px, 5.4vw, 24px); }

  .sp-row { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
}

/* ===========================================================
   THE ACCOUNT, TOP RIGHT        (2026-09-29, reworked 2026-10-02)
   -----------------------------------------------------------
   CJ, 2026-09-29: "the login logout needs to be at the top right,
   it's currently hard to find the logout button via mobile." It
   was missing entirely on phones. Since 2026-10-02 the top right
   is LOG IN when signed out, and when signed in your picture: one
   press opens the account menu, with Log out in it.
   Signed out, SIGN UP is the Join tab, so it is not repeated here.
   =========================================================== */
@media (max-width: 820px) {
  .site-header .nav-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
  .site-header .nav-actions .btn { white-space: nowrap; }
  .site-header .nav-actions [data-auth-open="signup"] { display: none; }
  .account-btn { padding: 3px; }
  .account-btn__chev { display: none; }
}


/* ===========================================================
   FINGERS, NOT WIDTHS                          (added 2026-09-29)
   -----------------------------------------------------------
   Everything above keys off width, which leaves an iPad held
   sideways (1024-1180px) on the desktop site: 36px buttons and
   15px fields that make iOS zoom in and stay zoomed.
   scripts/mobile-audit.mjs measured it: 0 of 60 page x size
   pairs met every target before this block.

   (pointer: coarse) is true on phones and tablets and false for
   a mouse or trackpad, so this block, like the rest of the file,
   cannot reach the PC site.

   The icon buttons keep their 32px look. The box grows to 44px
   (Apple's minimum) and the ring is redrawn as an inset shadow
   inside a transparent border. The negative margin gives the
   growth back, so the rows they sit in do not reflow.
   =========================================================== */
@media (pointer: coarse) {

  /* iOS zooms any field under 16px on focus. !important because this
     is a floor, not a style: .composer-box__field textarea and
     .field select both out-rank a bare element selector, and the
     audit caught both still at 15px. */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),
  textarea,
  select { font-size: 16px !important; }

  .play-btn,
  .composer-play,
  .sp-card__play {
    width: 44px; height: 44px;
    margin: -6px;
    border: 6px solid transparent;
    background-clip: padding-box;
    box-shadow: inset 0 0 0 1px var(--border-subtle);
  }
  .play-btn:hover,
  .composer-play:hover,
  .sp-card__play:hover {
    border-color: transparent;
    box-shadow: inset 0 0 0 1px var(--border-strong);
  }


  .site-header .btn,
  .btn-sm {
    min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
  }

  .logo { min-height: 44px; display: inline-flex; align-items: center; }

  .socials a {
    width: 44px; height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
  }

  /* Text links that stand alone as controls. The padding is handed
     back as negative margin so the text sits where it always did. */
  .ev-card__host,
  .panel__link,
  .view-all,
  .post__name-link,
  .footer-col a,
  .footer-soon,
  .contact-line a {
    display: inline-flex; align-items: center;
    min-height: 44px;
    margin-block: -12px;
  }
  .footer-col a { min-width: 44px; }
  .post__avatar-link { min-width: 44px; min-height: 44px; margin: -4px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-teal, .btn-ghost { min-height: 44px; }
  .rail a { min-height: 44px; }
  /* Found by the audit run against live, where there are real posts to
     measure: phones already had these at 44px, an iPad on its side got 34. */
  .post-action { min-height: 44px; }
  .ws-modal__close { min-width: 44px; min-height: 44px; }

  /* The same 44px anchor the phone already gets (platform.css, embed
     card titles), extended to an iPad on its side. */
  .embed-card__title { overflow: visible; }
  .embed-card__title > a {
    display: block;
    padding-block: 12px;
    margin-block: -12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 12px floor for reading at arm's length. The tab bar's 10px
     labels are left alone: that is the iOS system size. */
  .page-band__eyebrow,
  .ev-date span,
  .footer-col h4,
  .artist-country,
  .video-card .video-title,
  .song-artist,
  .footer-credit,
  .profile-head__handle,
  .profile-head__handle span,
  .site-header .nav-link,
  .rail__label,
  .sp-card__tags,
  .embed-plat { font-size: 12px; }
}
