/* Phase 6, feature 12 — what makes the templates more than a palette.
   Everything here keys off the body classes StorefrontTemplate writes: template-{family}, store-grid-N,
   store-density-*, store-nav-*, store-radius-*. The rules change structure — how many products fit in
   a row, whether the page has a rail, how much air the spacing scale gets — not just colours. */

/* Products per row, decided by the template and overridable by the merchant. */
body[class*="store-grid-"] .shop-grid{grid-template-columns:repeat(var(--grid,4),minmax(0,1fr))}
body.store-grid-2 .shop-grid{--grid:2}
body.store-grid-3 .shop-grid{--grid:3}
body.store-grid-4 .shop-grid{--grid:4}
body.store-grid-5 .shop-grid{--grid:5}
@media(max-width:980px){body[class*="store-grid-"] .shop-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:760px){body[class*="store-grid-"] .shop-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:420px){body.store-grid-5 .shop-grid,body.store-grid-4 .shop-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}

/* Spacing: one scale, three rhythms, applied to the properties the storefront already used.
   "comfortable" is exactly what every shop had before this feature (52px between sections, 18px grid
   gap), so a template that does not ask for a different rhythm looks untouched. */
body.store-density-compact .store-section{margin-top:34px}
body.store-density-comfortable .store-section{margin-top:52px}
body.store-density-airy .store-section{margin-top:74px}
body.store-density-compact .shop-grid{gap:12px}
body.store-density-comfortable .shop-grid{gap:18px}
body.store-density-airy .shop-grid{gap:24px}
body.store-density-airy .section-title{margin-bottom:26px}
body.store-density-compact .section-title{margin-bottom:12px}
body.store-density-airy .store-shell{width:min(100% - 40px,1120px)}
body.store-density-compact .store-shell{width:min(100% - 28px,1220px)}

/* Corners, from the template. Expressed through --radius, the variable every theme already uses, so a
   theme keeps its own idea of what should be square and what should be round. */
body.store-radius-square{--radius:0}
body.store-radius-soft{--radius:12px}
body.store-radius-round{--radius:20px}
body.store-radius-round .store-pill-nav a,body.store-radius-round .store-rail a{border-radius:999px}

/* The lookbook family reads like a magazine: bigger pictures, quieter captions, fewer per screen. */
body.template-lookbook .shop-card{background:transparent;border:0;box-shadow:none}
body.template-lookbook .shop-card-media{aspect-ratio:4/5}
body.template-lookbook .shop-card h3,body.template-lookbook .shop-product-name{font-size:1.02rem;letter-spacing:.01em}
body.template-lookbook .featured-collection .shop-grid{--grid:2}
@media(max-width:760px){body.template-lookbook .featured-collection .shop-grid{--grid:1}}
/* The catalog family is about density: shorter pictures, tighter cards, more visible at once. */
body.template-catalog .shop-card-media{aspect-ratio:1/1}
/* The boutique family sits between the two, with room around the words. */
body.template-boutique .shop-card{padding:4px}

/* Feature 12 — the collection pills. A strip under the header, scrollable on a phone, and it holds
   what the shop actually sells rather than a link to a page the customer has to find. */
.store-pill-nav{display:flex;gap:8px;align-items:center;overflow-x:auto;scrollbar-width:none;padding:10px 0;margin:0 auto;width:min(100% - 32px,1180px);-webkit-overflow-scrolling:touch}
.store-pill-nav::-webkit-scrollbar{display:none}
.store-pill-nav a{display:inline-flex;align-items:center;gap:6px;flex:0 0 auto;min-height:44px;padding:8px 16px;border:1px solid var(--line,#e6ddcd);border-radius:999px;background:var(--surface,#fff);color:var(--ink,#211d18);font-size:.86rem;font-weight:600;text-decoration:none;white-space:nowrap}
.store-pill-nav a:hover{border-color:var(--brand,#21503e);color:var(--brand,#21503e)}
.store-pill-nav a small{color:var(--muted,#78705f);font-weight:500}
body.store-density-compact .store-pill-nav{padding:7px 0}

/* The builder's ready-made layouts: one choice per row, the description next to it. */
.builder-presets{display:grid;gap:10px}
.builder-presets h2{margin:0}
.builder-preset-grid{display:grid;gap:10px;grid-template-columns:repeat(auto-fit,minmax(240px,1fr))}
.builder-preset{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border:1px solid var(--line,#e6ddcd);border-radius:12px;cursor:pointer}
.builder-preset:hover{border-color:var(--brand,#21503e)}
.builder-preset input{width:20px;height:20px;margin:2px 0 0;accent-color:var(--brand,#21503e);flex:0 0 auto}
.builder-preset span{display:grid;gap:3px;font-size:.86rem}
.builder-preset small{color:var(--muted,#78705f);font-weight:500;line-height:1.45}

/* Feature 12 — the side rail. Two genuinely different arrangements: a column beside the catalog on a
   wide screen, and the same links folded into the mobile bar on a small one. */
.store-body{display:block}
.store-body.is-rail{display:grid;grid-template-columns:216px minmax(0,1fr);gap:26px;align-items:start;width:min(100% - 32px,1240px);margin:0 auto}
.store-body.is-rail .store-shell{width:100%;margin:0}
.store-rail{position:sticky;top:16px;display:grid;gap:4px;padding:16px 14px;border:1px solid var(--line,#e6ddcd);border-radius:var(--radius,12px);background:var(--surface,#fff);margin-top:18px}
.rail-title{margin:0 0 6px;font-size:.72rem;letter-spacing:.14em;text-transform:uppercase;color:var(--muted,#78705f)}
.store-rail a{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:44px;padding:8px 10px;border-radius:8px;color:var(--ink,#211d18);font-size:.9rem;font-weight:600;text-decoration:none}
.store-rail a:hover{background:var(--canvas,#f8f4ec);color:var(--brand,#21503e)}
.store-rail a small{color:var(--muted,#78705f);font-weight:500}
.store-rail .rail-all{color:var(--brand,#21503e)}
.rail-children{display:grid;gap:2px;margin:0 0 6px 10px;padding-left:8px;border-left:1px solid var(--line,#e6ddcd)}
.rail-children a{min-height:36px;font-size:.82rem;font-weight:500;color:var(--muted,#78705f)}
body.store-nav-sidebar .store-desktop-links{display:none}
@media(max-width:900px){
  .store-body.is-rail{display:block;width:100%}
  .store-rail{display:none}
  body.store-nav-sidebar .store-desktop-links{display:flex}
}

/* Typography: the body font is the shop's, the display font is the headings'. They are the same
   unless the merchant asked for a separate display face. */
body.store-display-editorial h1,body.store-display-editorial h2,body.store-display-editorial h3{font-family:Georgia,"Times New Roman",serif}
body.store-display-rounded h1,body.store-display-rounded h2,body.store-display-rounded h3{font-family:"Trebuchet MS",ui-rounded,system-ui,sans-serif}
body.store-display-system h1,body.store-display-system h2,body.store-display-system h3{font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}

/* The brand colour reaches the chrome — header band, pills, rail — while --accent keeps owning buttons
   and highlights, so a brand colour cannot accidentally recolour every action. It only tints the header
   when the merchant actually chose a brand colour; the template palette alone leaves the shop as it was. */
body.has-brand .store-header{background:linear-gradient(180deg,color-mix(in srgb,var(--brand,#21503e) 7%,transparent),transparent)}
body .store-rail .rail-title,body .store-pill-nav a:hover{color:var(--brand,#21503e)}

/* ============================================================================
   Build-your-own navigation blocks: the dropdown menu and the side drawer.
   Both hang off one "Menu" trigger in the header and reuse the store's own
   --accent / --ink / --line tokens, so they inherit whatever the merchant picked.
   ============================================================================ */
.store-menu-trigger{display:inline-flex;align-items:center;gap:8px;background:transparent;border:1px solid var(--line,#e2e2dd);color:inherit;font:inherit;font-weight:600;padding:9px 14px;border-radius:var(--radius,10px);cursor:pointer;line-height:1}
.store-menu-trigger:hover{border-color:var(--accent,#ff5b1f)}
.store-menu-bars{width:16px;height:11px;position:relative;display:inline-block}
.store-menu-bars,.store-menu-bars::before,.store-menu-bars::after{border-top:2px solid currentColor}
.store-menu-bars::before,.store-menu-bars::after{content:"";position:absolute;left:0;right:0}
.store-menu-bars::before{top:4px}.store-menu-bars::after{top:9px}

/* Dropdown: a panel that drops under the header, collections in a wrapping grid. */
.store-dropdown-panel{position:relative;z-index:30;border-bottom:1px solid var(--line,#e2e2dd);background:var(--soft,#f6f5f1);max-height:0;overflow:hidden;opacity:0;transition:max-height .22s ease,opacity .18s ease}
.store-dropdown-panel.is-open{max-height:60vh;opacity:1}
.store-dropdown-inner{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:6px;max-width:1200px;margin:0 auto;padding:14px clamp(16px,4vw,40px)}
.store-dropdown-inner a{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:10px 12px;border-radius:10px;text-decoration:none;color:inherit;font-weight:600;background:#fff;border:1px solid var(--line,#e2e2dd)}
.store-dropdown-inner a:hover{border-color:var(--accent,#ff5b1f)}
.store-dropdown-inner small{color:var(--muted,#6b7079);font-weight:500}

/* Drawer: a scrim plus a panel that slides in from the inline-start edge. */
.store-drawer{position:fixed;inset:0;z-index:60}
.store-drawer .store-drawer-scrim{position:absolute;inset:0;width:100%;height:100%;border:0;padding:0;background:rgba(14,15,17,.45);opacity:0;transition:opacity .2s ease;cursor:pointer}
.store-drawer.is-open .store-drawer-scrim{opacity:1}
.store-drawer-panel{position:absolute;inset-block:0;inset-inline-start:0;width:min(320px,84vw);background:#fff;box-shadow:0 0 40px rgba(14,15,17,.25);transform:translateX(-102%);transition:transform .22s ease;display:flex;flex-direction:column;overflow-y:auto}
[dir="rtl"] .store-drawer-panel{transform:translateX(102%)}
.store-drawer.is-open .store-drawer-panel{transform:translateX(0)}
.store-drawer-head{display:flex;align-items:center;justify-content:space-between;padding:16px 18px;border-bottom:1px solid var(--line,#e2e2dd)}
.store-drawer-head strong{font-size:1.05rem}
.store-drawer-close{background:transparent;border:0;font-size:1.6rem;line-height:1;cursor:pointer;color:inherit;padding:0 4px}
.store-drawer-links{display:flex;flex-direction:column;padding:8px}
.store-drawer-links a{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:13px 14px;border-radius:10px;text-decoration:none;color:inherit;font-weight:600}
.store-drawer-links a:hover{background:var(--soft,#f6f5f1)}
.store-drawer-links small{color:var(--muted,#6b7079);font-weight:500}
body.store-menu-open{overflow:hidden}
