/* Anugraha Jewellers v2 — phone layout.
 *
 * Yashas chose option B on 2026-09-14: the desktop design stays exactly as drawn,
 * and a phone layout is added below it.
 *
 * EVERY rule in this file lives inside `@media (max-width: 899px)`. Above that
 * width this stylesheet contributes nothing at all, so the compiled design is
 * byte-for-byte what the Claude Design canvas shows. Nothing here is loaded or
 * applied on desktop.
 *
 * Why `!important` on nearly every line: the design carries all of its styling in
 * inline `style=""` attributes, and an inline style beats any stylesheet rule
 * except an `!important` one. This is the documented reason V2_PLAN §4.8
 * originally argued against compiling the design at all. Confined to one
 * breakpoint, it is the correct tool rather than a smell.
 *
 * Selectors match on inline-style content (`[style*="..."]`) because the design
 * has no classes to hook. They are written against the patterns actually present
 * in the compiled output, surveyed 2026-09-14.
 */

@media (max-width: 899px) {

  /* Decorative absolutely-positioned circles sit outside the viewport and would
     otherwise create a sideways scroll.
     `clip` rather than `hidden` only to avoid making html/body a scroll
     container, which browsers handle inconsistently. It has no bearing on the
     header: the design's own `<div style="overflow-x:hidden">` body wrapper is
     the ancestor that decides stickiness, and it is left exactly as the design
     wrote it — the header scrolls away, by design. See fix_sticky_wrapper() in
     scripts/dc_compile.py before changing anything here. */
  html, body { overflow-x: clip !important; }

  /* ---- containers: 32px side padding is too wide on a 390px screen ---- */
  [style*="max-width:1240px"] {
    padding-left: 20px !important;
    padding-right: 20px !important;
  }

  /* ---- header: let the row wrap, and give the nav its own line ---- */
  header [style*="flex-wrap:nowrap"] {
    flex-wrap: wrap !important;
    gap: 10px 14px !important;
  }
  /* the nav itself: allow it to wrap rather than run off the edge */
  header nav, header [style*="gap:30px"] {
    flex-wrap: wrap !important;
    gap: 14px 18px !important;
    font-size: 13px !important;
  }
  /* the search box: full width on its own line instead of a fixed 260px */
  header [style*="flex:0 1 260px"] {
    flex: 1 1 100% !important;
    margin-left: 0 !important;
  }

  /* ---- hero: stop forcing 640px of height, and stack text above the image ---- */
  [style*="min-height:640px"] {
    min-height: 0 !important;
    padding-top: 36px !important;
    padding-bottom: 56px !important;
  }

  /* ---- the general stacking rule ----
     Any flex row whose children declare min-width:280px is a two-up content band
     (hero halves, the Featured Pieces banners, the showroom block). Stack them and
     let the halves shrink. :has() keeps this surgical — small inline groups like
     the logo lockup are untouched because their children carry no min-width. */
  [style*="min-width:280px"] { min-width: 0 !important; width: 100% !important; }
  div:has(> [style*="min-width:280px"]) {
    flex-direction: column !important;
  }

  /* ---- grids ----
     Generic first, exceptions after. Enumerating the design's column ratios was
     tried and failed: `1.15fr .85fr` on Contact was missed and the form card
     overflowed by 64px. `fr` columns do not shrink below their content, so every
     multi-column grid has to be collapsed by default and the few that should
     stay multi-column named explicitly.
     Note the doubled attribute selector on the exceptions — they need at least
     the specificity of the generic rule to win. */
  [style*="display:grid"][style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 26px !important;
  }
  /* grid children must be allowed to shrink, or long words re-inflate the track */
  [style*="display:grid"] > * { min-width: 0 !important; }

  /* ...and they must not claim a SECOND column either.
     The rule above collapses every multi-column grid to `1fr`, but the design
     spans some form labels across two tracks (`grid-column:1/3`). On a grid with
     one explicit track that span CREATES AN IMPLICIT SECOND TRACK, sized to its
     content — so the explicit 1fr column gets only what is left.
     Measured on /contact at 390px before this rule: `grid-template-columns`
     computed to `70px 174px`, and the Name field rendered 70px wide, showing
     "Your n" while Phone sat at 174px beside it. The design's own declaration is
     `1fr 1fr`, i.e. equal halves, so honouring it on a phone means one full-width
     column each — this restores the design's intent rather than departing from it.
     `grid-column:1/3` appears on contact.html and enquiry.html only (7 elements,
     measured 2026-10-01), so this cannot reach the range strip or the footer. */
  [style*="display:grid"] > [style*="grid-column"] { grid-column: auto !important; }

  /* the five-category range strip stays two up */
  [style*="display:grid"][style*="grid-template-columns:repeat(5,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 14px !important;
  }
  /* the footer's four columns stay two up */
  [style*="display:grid"][style*="grid-template-columns:1.4fr 1fr 1fr 1.2fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 28px 20px !important;
  }

  /* ---- cards: 44px of padding is a third of a phone screen ---- */
  [style*="padding:44px"] { padding: 22px !important; }
  [style*="padding:48px"] { padding: 24px !important; }
  [style*="padding:56px"] { padding: 28px !important; }

  /* ---- vertical rhythm: the design's 96px section padding is a lot of empty
     screen on a phone ---- */
  [style*="padding:96px 32px"] { padding: 56px 20px !important; }
  [style*="padding:90px 32px"] { padding: 52px 20px !important; }
  [style*="padding:70px 32px"] { padding: 44px 20px !important; }

  /* ---- images inside stacked bands shouldn't keep a desktop-sized floor ---- */
  [style*="min-height:320px"] { min-height: 210px !important; }

  /* ---- decorative fixed-size circles ---- */
  [style*="width:420px"][style*="position:absolute"],
  [style*="width:340px"][style*="position:absolute"] {
    max-width: 60% !important;
    height: auto !important;
    aspect-ratio: 1 !important;
  }

  /* ---- the one genuinely fixed-size type in the design ---- */
  [style*="font-size:56px"] { font-size: 34px !important; }
  [style*="font-size:44px"] { font-size: 30px !important; }
  [style*="font-size:34px"] { font-size: 26px !important; }

  /* ---- forms: full-width controls ---- */
  input, select, textarea, button { max-width: 100% !important; }
}

/* A narrow phone needs a little more trimming than a large one. */
@media (max-width: 420px) {
  [style*="max-width:1240px"] {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  header [style*="gap:30px"] { gap: 10px 14px !important; font-size: 12px !important; }
}
