/* ============================================================
   mobile.css - the phone layout (22/10/2026)
   ============================================================

   Carl, on Android Chrome: on a phone Quorum should read like a market
   app - TradingView's watchlist - and the desktop view must not change.
   What he measured on the old layout, and what each part of this file
   answers:

     the header row ran off the right edge     -> bottom tab bar, header
       ("Pricing" cut; 11px sideways scroll       reduced to the lockup and
       at 390px, measured locally)                the account links
     the filters took half the screen          -> bottom sheet
     tall rows, clipped columns                -> .watchlist: one dense row
                                                  per company

   HOW THE DESKTOP STAYS PUT. Two rules, and they are the contract for
   anyone editing this file:
     1. Outside the media query this file only HIDES the elements it
        adds (tab bar, sheet controls, phone-only footer links).
     2. Every rule that touches something already on the page lives
        inside @media (max-width: 640px) - the breakpoint style.css and
        quorum.css already use for phones.
   It loads last (base.html), so at equal specificity it wins over the
   640px rules in quorum.css that it replaces; where style.css's
   `table.leaderboard td` (0-1-2) would win, the selectors here carry
   .watchlist to outrank it.

   Palette: tokens only (--gold, --bg, --bg-elevated, --border, --fg,
   --muted). No new colour. */

/* ---------- Hidden everywhere but on a phone ---------- */

.tab-bar,
.footer-mobile,
.sheet-toggle,
.sheet-open,
.sheet-backdrop,
.sheet-head,
.research-banner,
.m-only {
  display: none;
}

@media (max-width: 640px) {

  /* ---------- Room for the tab bar ---------- */

  /* 56px tab bar + the iPhone home-indicator inset. Without it the last
     row of every page, and the footer, sit under the bar. */
  body {
    /* 64px tab bar + 26px disclaimer band + the home indicator. */
    padding-bottom: calc(64px + 26px + env(safe-area-inset-bottom));
  }
  main { padding: 0.9rem 0.85rem 1.25rem; }

  /* ---------- Header: lockup on the left, account on the right ---------- */

  .site-header {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 0.45rem;
    padding: 0.55rem 0.85rem;
  }
  .site-header .brand { grid-row: 1; }
  /* The sections moved to the tab bar. This is what removed the
     overflow: five links plus their hairlines measured wider than a
     390px screen. */
  .site-header .header-nav { display: none; }
  .site-header .header-account {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    gap: 0.6rem;
  }
  .site-header .header-search {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  /* The lockup without its two tagline lines: on a phone the header is a
     toolbar, and the taglines cost two lines of every screen. */
  .brand-tagline { display: none; }
  .brand-mark { height: 28px; width: 28px; }
  /* Profile is the Account tab now; keeping it here would put the same
     destination on screen twice. */
  .header-account-link[href="/profile"] { display: none; }
  .header-signin { font-size: 0.66rem; white-space: nowrap; }
  .header-register {
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    padding: 0.5rem 0.6rem;
  }

  /* ---------- Bottom tab bar ---------- */

  .tab-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: 64px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--muted);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    -webkit-tap-highlight-color: transparent;
  }
  .tab svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .tab[aria-current="page"] { color: var(--gold); }
  .tab[aria-current="page"]::before {
    content: "";
    position: absolute;
    top: 0;
    left: 22%;
    right: 22%;
    height: 2px;
    background: var(--gold);
  }
  .tab:active { background: var(--bg-hover); }

  /* Disclaimer band, fixed just above the tab bar. 26px, always in view. */
  .research-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(64px + env(safe-area-inset-bottom));
    z-index: 40;
    height: 26px;
    margin: 0;
    background: var(--bg-elevated);
    color: var(--muted);
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 26px;
  }

  .site-footer { padding-bottom: 1.25rem; }
  .footer-mobile { display: inline; }

  /* ---------- Intro and notices, tighter ---------- */

  .public-intro h1 { font-size: 1.35rem; margin-bottom: 0.4rem; }
  .public-lead { font-size: 0.9rem; line-height: 1.5; }
  .cta-line { font-size: 0.66rem; line-height: 1.55; }

  /* ---------- The watchlist ---------- */

  /* The table stops being a table below 640px: each row becomes a
     two-line grid, like a market app's watchlist.

       [*]  SYMBOL  Archived          /\/\_/   [Bullish][82/100]
            Activity 2026-10-20       (1y)         Scored 2026-10-21

     Kept: favourite star (when the viewer can hold favourites), symbol,
     the band chip and the score beside it (Plus+; below Plus the score
     is not in the page at all), the date the score was produced, the
     last insider activity and the one-year trend. Everything else is on
     the company page, one tap away: row-click.js already sends a tap
     anywhere on the row to /stock/{symbol}, and the symbol stays a
     real link for the keyboard. */
  .table-scroll:has(> table.watchlist) { overflow-x: visible; }
  table.leaderboard.watchlist {
    display: block;
    min-width: 0;
    width: 100%;
  }
  table.leaderboard.watchlist tbody {
    display: flex;
    flex-direction: column;
  }

  /* Sorting survives as a row of chips: the header cells that are sort
     links (Plus+) line up and scroll sideways; plain-text headers
     (anonymous, Free) are dropped, and so is the whole strip when no
     header is a link. */
  table.leaderboard.watchlist thead { display: block; }
  table.leaderboard.watchlist thead:not(:has(a)) { display: none; }
  table.leaderboard.watchlist thead tr {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 0 0.6rem;
    border-bottom: 1px solid var(--border);
  }
  table.leaderboard.watchlist thead tr::-webkit-scrollbar { display: none; }
  table.leaderboard.watchlist thead th { display: none; }
  table.leaderboard.watchlist thead th:has(> a) {
    display: block;
    flex: none;
    padding: 0;
    border: 0;
    width: auto;
  }
  table.leaderboard.watchlist thead th a {
    display: inline-block;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.6rem;
  }
  table.leaderboard.watchlist thead th.sorted a {
    color: var(--gold);
    border-color: var(--gold-dim);
  }
  /* The active sort leads the strip, so the order the list is in is
     never scrolled out of sight (sorting by Bought put it sixth). */
  table.leaderboard.watchlist thead th.sorted { order: -1; }

  table.leaderboard.watchlist tbody tr[data-symbol] {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px auto;
    grid-template-areas:
      "sym  spark sig"
      "meta spark when";
    column-gap: 0.55rem;
    row-gap: 0.1rem;
    align-items: center;
    box-sizing: border-box;
    height: 64px;
    min-height: 64px;
    max-height: 64px;
    padding: 0 0.15rem;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
  }
  /* The star column only when it holds a star: an anonymous row's
     fav-col is an empty cell and must not cost the row a gap. */
  table.leaderboard.watchlist tbody tr[data-symbol]:has(> td.fav-col:not(:empty)) {
    grid-template-columns: auto minmax(0, 1fr) 72px auto;
    grid-template-areas:
      "fav sym  spark sig"
      "fav meta spark when";
  }
  table.leaderboard.watchlist tbody tr[data-symbol]:active { background: var(--bg-hover); }

  table.leaderboard.watchlist tbody td {
    display: none;
    padding: 0;
    border: 0;
    width: auto;
    min-width: 0;
  }
  table.leaderboard.watchlist td.fav-col:not(:empty) { display: block; grid-area: fav; }
  table.leaderboard.watchlist td.symbol-cell {
    display: block;
    grid-area: sym;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  table.leaderboard.watchlist .symbol-link {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
  }
  table.leaderboard.watchlist td.col-last {
    display: block;
    grid-area: meta;
    font-size: 0.66rem;
    color: var(--muted);
    white-space: nowrap;
  }
  table.leaderboard.watchlist td.col-last::before { content: "Activity "; }
  table.leaderboard.watchlist td.spark-cell {
    display: flex;
    grid-area: spark;
    align-items: center;
    justify-content: center;
  }
  table.leaderboard.watchlist td.spark-cell svg,
  table.leaderboard.watchlist td.spark-cell svg.price-spark.trend-up,
  table.leaderboard.watchlist td.spark-cell svg.price-spark.trend-down {
    width: 72px;
    height: 24px;
    max-width: 72px;
    color: var(--muted);
  }
  table.leaderboard.watchlist td.ai-col {
    display: flex;
    grid-area: sig;
    justify-content: flex-end;
    gap: 0.25rem;
    text-align: right;
  }
  /* Opinion pills (Bullish / Bearish / Neutral) leave the phone row.
     The desktop still paints them; .m-score is the replacement. */
  table.leaderboard.watchlist td.ai-col .q-chip { display: none; }
  table.leaderboard.watchlist .m-score {
    display: block;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--fg);
  }
  table.leaderboard.watchlist .m-extreme-hi { color: var(--gold); font-size: 11px; }
  table.leaderboard.watchlist .m-extreme-lo { color: var(--fg); font-size: 11px; }
  table.leaderboard.watchlist td.scored-cell {
    display: block;
    grid-area: when;
    text-align: right;
    font-size: 0.6rem;
    color: var(--muted);
    white-space: nowrap;
  }
  table.leaderboard.watchlist td.scored-cell:has(time)::before { content: "Scored "; }
  table.leaderboard.watchlist td.scored-cell .date-full { display: none; }
  table.leaderboard.watchlist td.scored-cell .date-short { display: inline; }
  table.leaderboard.watchlist tr.has-company td.col-last::before { content: none; }
  table.leaderboard.watchlist tr.has-company .activity-date { display: none; }
  table.leaderboard.watchlist .m-sub {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 400;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  table.leaderboard.watchlist tr.m-extreme { order: -1; }
  table.leaderboard.watchlist tr.m-section {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    height: auto;
    max-height: none;
    min-height: 28px;
    margin: 0;
    padding: 0.4rem 0.15rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
  }
  table.leaderboard.watchlist tr.m-section > td {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0;
  }
  table.leaderboard.watchlist tr.m-section-extreme { order: -2; }
  table.leaderboard.watchlist tr.m-section-highest { order: 0; }
  .m-section-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .m-extreme-empty { display: none; }
  table.leaderboard.watchlist tbody:not(:has(tr.m-extreme)) .m-extreme-empty {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
  }

  /* Favorites uses the same right-hand slot as the other watchlists
     (ai-col → sig, scored-cell → when). Bought used to sit in `sig`
     because this page had no AI column; that rule covered the score.
     The dollar figure stays a desktop cell.

     The ranking hides .q-chip below 640px and paints .m-score instead.
     On this page that hide removes the column: below Plus there is no
     .m-score, so the band — the only AI reading a free account has —
     disappears. The pills stay. .m-score would print the same 0-100 a
     second time at Plus, so it stays off. The chips are compact, the
     symbol track keeps a readable minimum, and a row that is still
     wider than the pane scrolls inside .table-scroll. The page does
     not. */
  .table-scroll:has(> table.leaderboard.watchlist.watchlist-favorites) {
    overflow-x: auto;
    max-width: 100%;
  }
  table.leaderboard.watchlist.watchlist-favorites tbody tr[data-symbol],
  table.leaderboard.watchlist.watchlist-favorites tbody tr[data-symbol]:has(> td.fav-col:not(:empty)) {
    grid-template-columns: auto minmax(4.5rem, 1fr) 72px max-content;
  }
  table.leaderboard.watchlist.watchlist-favorites td.symbol-cell {
    min-width: 4.5rem;
  }
  table.leaderboard.watchlist.watchlist-favorites td.ai-col {
    flex: none;
    width: max-content;
    max-width: 6.75rem;
    gap: 0.2rem;
  }
  table.leaderboard.watchlist.watchlist-favorites td.ai-col .q-chip {
    display: inline-flex;
    flex: none;
    font-size: 0.56rem;
    letter-spacing: 0.02em;
    padding: 0.1rem 0.28rem;
  }
  table.leaderboard.watchlist.watchlist-favorites td.ai-col .m-score {
    display: none;
  }
  table.leaderboard.watchlist.watchlist-favorites td.ai-col .q-none {
    font-size: 0.56rem;
    letter-spacing: 0.02em;
  }

  /* The anonymous cap and the empty-table message are rows without a
     company: plain blocks, full width. */
  table.leaderboard.watchlist tbody tr:not([data-symbol]) { display: block; }
  table.leaderboard.watchlist tbody tr:not([data-symbol]) > td {
    display: block;
    padding: 1rem 0.15rem 0.5rem;
  }

  /* ---------- Filters: a bottom sheet ---------- */

  .table-controls {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
  }
  /* Visually hidden but focusable: Tab reaches it, Space opens the
     sheet. display:none would take it out of the keyboard path. */
  .sheet-toggle {
    display: block;
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
  }
  .sheet-open {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg);
    cursor: pointer;
  }
  .sheet-open svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
  }
  .sheet-toggle:focus-visible + .sheet-open {
    outline: 2px solid var(--fg);
    outline-offset: 2px;
  }
  .sheet-count {
    display: inline-block;
    min-width: 1.2rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--gold);
    color: var(--bg);
    text-align: center;
    font-weight: 600;
  }

  .sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .sheet-toggle:checked ~ .sheet-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  /* Closed: off screen AND visibility:hidden, so its controls leave the
     tab order. The visibility change is delayed to the end of the slide
     so the sheet is seen leaving. */
  .table-controls .table-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.8rem;
    max-height: 80vh;
    overflow-y: auto;
    padding: 0.9rem 1rem calc(1.1rem + env(safe-area-inset-bottom));
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.6);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }
  .sheet-toggle:checked ~ .table-toolbar {
    transform: none;
    visibility: visible;
    transition: transform 0.22s ease;
  }
  .sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .sheet-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1rem;
  }
  .sheet-close {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0.5rem 0 0.5rem 0.75rem;
    cursor: pointer;
  }
  .table-controls .table-toolbar-field,
  .table-controls .table-toolbar-field select {
    width: 100%;
  }
  .table-controls .table-toolbar-field select { min-height: 44px; }
  .table-controls .table-toolbar-check { min-height: 36px; }
  .table-controls .table-toolbar-apply,
  .table-controls .table-toolbar-export {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
  }
  /* Active filters stay visible while the sheet is closed, on one
     line that scrolls sideways rather than wrapping down the page. */
  .table-controls .table-chips {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    max-width: 100%;
    margin: 0;
  }
  .table-controls .table-chip { flex: none; }

  /* À propos: a long FMP description stays four lines until "Lire plus".
     Desktop keeps the full paragraph (the control is display:none there). */
  .company-about .about-copy.is-clamped .about-description {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
  }
  .company-about .about-copy.is-clamped .about-more-open { display: inline-block; }
  .company-about .about-more-toggle:checked ~ .about-description {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
  }
  .company-about .about-more-toggle:checked ~ .about-more-open { display: none; }
  .company-about .about-more-toggle:checked ~ .about-more-close { display: inline-block; }

  /* ---------- Phone screen titles, Insiders rows, Plus ---------- */

  .m-screen-head { display: block; margin: 0 0 0.6rem; }
  .m-screen-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 20px;
    line-height: 1.2;
    margin: 0 0 0.25rem;
  }
  .m-screen-meta {
    margin: 0 0 0.75rem;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
  }
  .m-screen-meta a { color: var(--muted); }

  .dir-word { display: none; }
  .m-ps {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 20px;
    height: 20px;
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
  }
  .m-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "id amt"
      "id filed";
    column-gap: 0.55rem;
    align-items: center;
    box-sizing: border-box;
    min-height: 64px;
    height: 64px;
    padding: 0;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
  }
  .m-row .m-row-id { grid-area: id; min-width: 0; }
  .m-row .symbol-link {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 16px;
    color: var(--fg);
    text-decoration: none;
  }
  .m-row .m-sub { margin: 0; }
  .m-row .m-amt {
    grid-area: amt;
    margin: 0;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
  }
  .m-row .m-filed {
    grid-area: filed;
    margin: 0;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--muted);
  }
  .m-row .m-ps { grid-area: ps; justify-self: end; }
  .m-row:has(.m-ps) {
    grid-template-columns: minmax(0, 1fr) 20px auto;
    grid-template-areas:
      "id ps amt"
      "id filed filed";
  }
  .m-row-sales .symbol-link { color: var(--muted); }
  .m-cluster {
    justify-self: end;
    border: 1px solid var(--gold);
    border-radius: 999px;
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 10px;
    line-height: 18px;
    padding: 0 0.4rem;
  }
  .m-seg {
    display: flex;
    gap: 0.4rem;
    margin: 0 0 0.75rem;
  }
  .m-seg a {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 10px;
    text-decoration: none;
  }
  .m-seg a[aria-current="page"] {
    color: var(--gold);
    border-color: var(--gold);
  }
  .sales-only {
    margin: 0.4rem 0 0.8rem;
    background: var(--bg-elevated);
  }
  .sales-only summary {
    min-height: 36px;
    padding: 0.45rem 0.15rem;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    cursor: pointer;
  }
  .sales-only summary::before { content: "▶  "; }
  .sales-only[open] summary::before { content: "▼  "; }
  .m-calc {
    margin: 0.8rem 0 0;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
  }
  .m-plus {
    display: flex;
    flex-direction: column;
  }
  .m-plus a {
    display: flex;
    align-items: center;
    min-height: 48px;
    border-bottom: 1px solid var(--border);
    color: var(--fg);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
  }

  /* Light plate. Opt-in (?theme=light). Dark stays the default tokens.
     Gold is the darkened value so it clears 4.5:1 on Bone. */
  html[data-theme="light"] {
    color-scheme: light;
    --bg: #f2f0ea;
    --bg-elevated: #e8e5dc;
    --bg-hover: #dedbd2;
    --fg: #0a0a09;
    --muted: #5e5c55;
    --border: #cfcbc0;
    --gold: #7a6418;
    --gold-bright: #7a6418;
    --gold-dim: rgba(122, 100, 24, 0.35);
    background: var(--bg);
  }
  /* style.css paints the sticky header with a near-black cap
     (#0c0c0b → --bg). On Bone that cap is a dark band. */
  html[data-theme="light"] body,
  html[data-theme="light"] .site-header {
    background: var(--bg);
  }
  html[data-theme="light"] .site-header {
    box-shadow: 0 1px 0 var(--border);
  }
}

@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .table-controls .table-toolbar,
  .sheet-toggle:checked ~ .table-toolbar,
  .sheet-backdrop { transition: none; }
}
