/* ==========================================================================
   SORZIA — mobile.css
   --------------------------------------------------------------------------
   The phone build. Loaded last so it always wins the cascade, and scoped
   entirely inside max-width queries so desktop is untouched.

   Content is identical to desktop; the composition, density and atmosphere
   are not. Phones get a tighter type scale, table-free layouts, and a
   deeper cinematic environment.

   Palette, background colours and the Optical Destiny Lens are unchanged.
   ========================================================================== */

@media (max-width: 899px) {

  /* ------------------------------------------------------------------
     1. Safe areas — notches and home indicators
     ------------------------------------------------------------------ */
  .site-header .shell-wide {
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
  }

  .site-footer { padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom)); }

  /* The toolbar floats over the scene rather than sitting on a slab. */
  .site-header::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(2, 5, 11, 0.92), rgba(2, 5, 11, 0.55) 62%, transparent);
    opacity: 1;
    transition: opacity var(--dur-state) var(--ease-premium);
  }

  .site-header.is-stuck::before { opacity: 0; }

  .header-inner { position: relative; z-index: 1; }

  /* ------------------------------------------------------------------
     2. Type — one step down, tighter rhythm
     ------------------------------------------------------------------ */
  :root {
    --step--2: 0.66rem;
    --step--1: 0.75rem;
    --step-0:  0.875rem;
    --step-1:  0.95rem;
    --step-2:  1.1rem;
    --step-3:  1.35rem;
  }

  body { line-height: 1.5; }

  h2 { letter-spacing: -0.018em; }
  h3 { letter-spacing: -0.012em; }

  .section { padding-block: clamp(1.75rem, 7vw, 2.5rem); }
  .section-tight { padding-block: clamp(1.5rem, 6vw, 2rem); }
  .section-head { margin-bottom: var(--sp-4); gap: 0.4rem; }
  .lede { font-size: var(--step-0); line-height: 1.5; }
  .prose > * + * { margin-top: 0.85rem; }
  .prose h2 { margin-top: var(--sp-5); }
  .prose h3 { margin-top: var(--sp-4); }

  /* Ornamental rules eat width that headings need on a phone. */
  .rule-heading::before,
  .rule-heading::after { max-width: 28px; }
  .rule-heading { gap: 0.6rem; }

  /* ------------------------------------------------------------------
     3. Tabs and pills — one scrollable rail, never a wrapped block
     ------------------------------------------------------------------ */
  .filter-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 0.15rem 1.25rem 0.55rem;
    margin-inline: -1.25rem;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 26px, #000 calc(100% - 26px), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 26px, #000 calc(100% - 26px), transparent 100%);
  }

  .filter-row::-webkit-scrollbar { display: none; }
  .filter-btn { flex: 0 0 auto; white-space: nowrap; }

  /* .segmented keeps its own pill border, so it cannot bleed to the screen
     edge the way .filter-row does — only the content inside gets a fade,
     right where it meets the tray's own rounded edge. */
  .segmented {
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
    mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
  }
  .filter-btn { flex: 0 0 auto; white-space: nowrap; }

  /* A tag is a label, not a full-width bar. As a grid item it was
     stretching edge to edge inside the card. */
  .tag { justify-self: start; align-self: start; width: auto; }

  /* ------------------------------------------------------------------
     4. Tables become stacked records
     ------------------------------------------------------------------
     A four-column comparison cannot be read on a 390px screen. Each row
     becomes its own small card, with the column name carried by the cell.
     ------------------------------------------------------------------ */
  .table-scroll { overflow: visible; }

  .matrix-table,
  .matrix-table tbody,
  .matrix-table tr,
  .matrix-table th,
  .matrix-table td { display: block; width: 100%; }

  .matrix-table thead { display: none; }

  .matrix-table tr {
    margin-bottom: 0.7rem;
    padding: 0.9rem 1rem;
    border-radius: var(--r-md);
    background:
      linear-gradient(168deg, rgba(231, 201, 125, 0.05), rgba(255, 255, 255, 0.012) 44%, transparent),
      var(--glass-1);
    border: 1px solid rgba(255, 255, 255, 0.055);
    box-shadow: inset 0 1px 0 rgba(255, 250, 235, 0.07);
  }

  .matrix-table tbody th {
    padding: 0 0 0.55rem;
    border: 0;
    font-size: var(--step-1);
    font-weight: 620;
    color: var(--gold-bright);
    letter-spacing: -0.01em;
  }

  .matrix-table td {
    padding: 0.5rem 0 0;
    border: 0;
    font-size: var(--step-0);
    line-height: 1.45;
  }

  .matrix-table td + td { border-top: 1px solid var(--hairline); margin-top: 0.5rem; }

  .matrix-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.15rem;
    font-size: var(--step--2);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
  }

  /* ------------------------------------------------------------------
     5. Cards and instruments — denser, still cinematic
     ------------------------------------------------------------------ */
  .card { padding: 1rem 1.05rem; gap: 0.5rem; }
  .panel-pad { padding: 1rem; }

  .article-card.stacked .article-thumb { aspect-ratio: 2 / 1; }
  .article-card.stacked .article-body { padding: 0.85rem 1rem 1rem; gap: 0.35rem; }
  .article-card h3 { font-size: var(--step-1); }

  .system-block { gap: 0.9rem; }
  .system-visual .viz { width: min(72%, 200px); }
  .feature-list { gap: 0.45rem; }
  .feature-list li { font-size: var(--step-0); }

  .pillar-card { gap: 0.85rem; }
  .pillar-emblem { width: 74px; height: 74px; }

  .value-grid, .pillar-grid, .article-row, .cols-2, .cols-3 { gap: 0.7rem; }

  .process-step { padding: 0.9rem 1rem; }
  .timeline li { padding-bottom: var(--sp-3); }

  .summary-panel { padding: 1rem; }
  .profile-list li { padding: 0.55rem 0.1rem; }
  .insight-list li { font-size: var(--step-0); }

  /* ------------------------------------------------------------------
     6. AAA atmosphere — depth the desktop does not need
     ------------------------------------------------------------------
     Two slow aurora fields drift behind the content and shift a little as
     the page scrolls. Pure transform/opacity on two elements, so it costs
     almost nothing on a mid-range phone.
     ------------------------------------------------------------------ */
  .aurora {
    position: fixed;
    inset: -20% -30%;
    z-index: -2;
    pointer-events: none;
    opacity: 0.85;
    transform: translate3d(0, calc(var(--scroll, 0) * -26px), 0);
    will-change: transform;
  }

  .aurora::before,
  .aurora::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
  }

  .aurora::before {
    width: 78vw;
    height: 78vw;
    left: -18vw;
    top: 8vh;
    background: radial-gradient(circle, rgba(98, 85, 199, 0.30), transparent 68%);
    animation: auroraDriftA 26s var(--ease) infinite alternate;
  }

  .aurora::after {
    width: 66vw;
    height: 66vw;
    right: -14vw;
    top: 46vh;
    background: radial-gradient(circle, rgba(188, 145, 59, 0.22), transparent 68%);
    animation: auroraDriftB 32s var(--ease) infinite alternate;
  }

  @keyframes auroraDriftA {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to   { transform: translate3d(9vw, 7vh, 0) scale(1.14); }
  }

  @keyframes auroraDriftB {
    from { transform: translate3d(0, 0, 0) scale(1.08); }
    to   { transform: translate3d(-8vw, -9vh, 0) scale(1); }
  }

  /* The star/constellation field drifts against the aurora as you scroll —
     the parallax that sells depth on a small screen. */
  .sky::before { transform: translate3d(0, calc(var(--scroll, 0) * 40px), 0); }

  /* Sections arrive with a cinematic rise instead of a plain fade. */
  .js .reveal { transform: translateY(18px) scale(0.994); }
  .js .reveal.is-visible { transform: none; }

  /* A gold edge catches the light as each panel settles in. */
  .js .panel.reveal::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(115deg, transparent 34%, rgba(242, 222, 172, 0.10) 50%, transparent 66%);
  }

  .js .panel.reveal.is-visible::after { animation: panelSheen 1100ms var(--ease-premium) 1; }

  @keyframes panelSheen {
    0%   { opacity: 0; transform: translateX(-24%); }
    35%  { opacity: 1; }
    100% { opacity: 0; transform: translateX(24%); }
  }

  /* ------------------------------------------------------------------
     7. Footer
     ------------------------------------------------------------------ */
  .site-footer { margin-top: var(--sp-5); padding-top: var(--sp-5); }
  .footer-grid { gap: var(--sp-4); }
  .footer-bottom { margin-top: var(--sp-4); gap: 0.5rem; }
  .footer-note { font-size: var(--step--2); }
}

/* Small phones: the last squeeze. */
@media (max-width: 380px) {
  :root { --step-3: 1.25rem; --step-2: 1.05rem; }
  .card { padding: 0.9rem; }
  .matrix-table tr { padding: 0.8rem 0.85rem; }
}

/* Nothing above should move for visitors who asked for stillness. */
@media (prefers-reduced-motion: reduce) {
  .aurora, .aurora::before, .aurora::after { animation: none; transform: none; }
  .sky::before { transform: none; }
  .js .panel.reveal.is-visible::after { animation: none; }
}
