/*
 * MATT Orthodontics storefront — hand-written CSS, no framework.
 * Brand red from the MATT logo; mobile-first (NFR-1); AA contrast and
 * visible focus (NFR-3). Loaded as a file so the strict CSP stays intact.
 */
:root {
    /* Matte Classic defaults. The live theme (Admin → Appearance) overrides these from /theme.css. */
    --brand: #ab2338;          /* matte MATT red */
    --brand-dark: #8c1d2e;
    --brand-tint: #f2e1e1;
    --brand-ink: #ffffff;
    --brand-line: #d9a8ae;
    --tint-ink: #8c1d2e;
    --link: #ab2338;
    --ink: #2a2b2e;
    --ink-soft: #45474b;
    --muted: #66676a;
    --line: #d8d4ce;
    --field-border: #8f8d89;
    --bg: #f5f3f0;
    --surface: #ece9e4;
    --surface-2: #e1ddd8;
    --header-bg: rgba(245, 243, 240, .96);
    --header-bar: #ab2338;
    --footer-bg: #2b2c2f;
    --footer-ink: #e9e7e3;
    --footer-muted: #b4b1ab;
    --photo-bg: #ffffff;
    --warn-bg: #fbf1e3;
    --warn-ink: #7a4100;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 1px 0 rgba(30, 28, 25, .04);
    --shadow-hover: 0 6px 18px rgba(30, 28, 25, .08);
    --grain: none;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-heading: Avenir, "Avenir Next", Montserrat, Corbel, "URW Gothic", "Segoe UI", sans-serif;
    --color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font: 16px/1.6 var(--font-body);
    color: var(--ink);
    background-color: var(--bg);
    background-image: var(--grain);       /* fine matte grain (Admin → Appearance) */
    color-scheme: var(--color-scheme);
    text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; }

a { color: var(--link); text-underline-offset: 2px; }
h1, h2, h3, .brand { font-family: var(--font-heading); letter-spacing: -.01em; }
a:hover { color: var(--link); text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 900px) { .container { padding: 0 24px; } }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 8px; background: var(--bg); padding: 8px 12px; z-index: 50; border-radius: var(--radius-sm); box-shadow: var(--shadow); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3 { line-height: 1.2; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: 1.9rem; margin: 0 0 14px; }
h2 { font-size: 1.35rem; margin: 32px 0 14px; }
h3 { font-size: 1.05rem; margin: 0 0 6px; }
@media (min-width: 900px) { h1 { font-size: 2.3rem; } }

.muted { color: var(--muted); }
.lead { font-size: 1.12rem; color: var(--ink-soft); }
.breadcrumb { font-size: .9rem; margin-bottom: 14px; color: var(--muted); }
.breadcrumb a { color: var(--muted); }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 20;
    background: var(--header-bg);
    border-bottom: 1px solid var(--line);
}
@media (max-width: 699px) { .site-header { position: static; } } /* the wrapped nav would cover too much of a phone screen */
.site-header::before { content: ""; display: block; height: 4px; background: var(--header-bar); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; padding-block: 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; text-decoration: none; color: var(--ink); letter-spacing: -.01em; line-height: 1.15; }
.brand img { width: 46px; height: auto; }
.brand:hover { color: var(--ink); }
.brand small { display: block; font-weight: 600; font-size: .7rem; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }

.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 4px; align-items: center; }
.nav a, .nav summary { display: inline-block; padding: 8px 10px; border-radius: var(--radius-sm); text-decoration: none; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.nav a:hover, .nav summary:hover { background: var(--surface); color: var(--ink); }
.nav .active { color: var(--link); }
.nav summary { list-style: none; }
.nav summary::-webkit-details-marker { display: none; }
.nav summary::after { content: " ▾"; font-size: .75em; }
.nav details[open] > summary::after { content: " ▴"; }
.nav .has-sub { position: relative; }
.nav .sub {
    list-style: none; margin: 6px 0 0; padding: 8px; position: absolute; top: 100%; left: 0; min-width: 250px; z-index: 30;
    background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-hover);
}
.nav .sub a { display: block; font-weight: 500; }
.nav .nav-cart a { background: var(--brand); color: var(--brand-ink); }
.nav .nav-cart a:hover { background: var(--brand-dark); color: var(--brand-ink); }

main { padding-block: 28px 56px; }

/* ---------- Buttons & badges ---------- */
.button {
    display: inline-block; font: inherit; font-weight: 700; padding: 11px 20px; border-radius: var(--radius-sm);
    border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); cursor: pointer; text-decoration: none; line-height: 1.2;
    transition: background-color .15s, box-shadow .15s;
}
.button:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: var(--brand-ink); }
.button.secondary { background: var(--bg); color: var(--link); }
.button.secondary:hover { background: var(--brand-tint); color: var(--brand-dark); }
.button.small { padding: 7px 13px; font-size: .9rem; }
.button.danger { background: #b3261e; border-color: #b3261e; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; cursor: pointer; }
.badge { display: inline-block; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.badge-brand { background: var(--brand-tint); border-color: var(--brand-line); color: var(--tint-ink); }
.price { font-weight: 800; color: var(--ink); }

/* ---------- Hero ---------- */
.hero {
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: center; margin: 0 0 8px; padding: 28px 22px;
    border: 1px solid var(--line); border-radius: var(--radius-lg);
    background: radial-gradient(520px 260px at 92% 40%, var(--brand-tint), transparent 70%), linear-gradient(180deg, var(--bg) 0%, var(--surface) 100%);
}
.hero-eyebrow { margin: 0 0 10px; font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--link); }
.hero h1 { margin: 0; font-size: clamp(1.55rem, 1.1rem + 1.6vw, 2.25rem); line-height: 1.15; letter-spacing: -.02em; max-width: 24ch; }
.hero .lead { margin: 14px 0 0; color: var(--ink-soft); font-size: 1.05rem; max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 0; }
.hero-actions .button { border-radius: 999px; padding: 11px 22px; }
.button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.button.ghost:hover { background: var(--bg); color: var(--link); border-color: var(--brand); }
.hero-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 104px), 1fr)); gap: 14px 20px; max-width: 520px; margin: 26px 0 0; padding: 18px 0 0; list-style: none; border-top: 1px solid var(--line); }
.hero-facts li { display: flex; flex-direction: column; line-height: 1.25; }
.hero-facts strong { font-size: 1.05rem; color: var(--ink); }
.hero-facts span { font-size: .85rem; color: var(--muted); }
.hero-media { display: none; margin: 0; text-align: center; }
.hero-product { display: block; overflow: hidden; border-radius: 50%; aspect-ratio: 1; max-width: 320px; margin: 0 auto; padding: 14%; background: var(--photo-bg); box-shadow: var(--shadow-hover); }
.hero-product img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; transition: transform .3s; } /* drops the photo's off-white backdrop */
.hero-product:hover img { transform: scale(1.04); }
.hero-media figcaption { margin-top: 12px; font-size: .85rem; font-weight: 600; }
.hero-media figcaption a { color: var(--muted); text-decoration: none; }
.hero-media figcaption a:hover { color: var(--link); }
.hero-mark { width: 260px; opacity: .9; }
@media (prefers-reduced-motion: reduce) { .hero-product img { transition: none; } .hero-product:hover img { transform: none; } }
@media (min-width: 860px) {
    .hero { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; padding: 40px 48px; }
    .hero-media { display: block; }
}

/* ---------- Grids, cards ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 18px; list-style: none; margin: 0; padding: 0; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1180px) { .grid.grid-4 { grid-template-columns: repeat(4, 1fr); } }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--bg); box-shadow: var(--shadow); }
.card a { text-decoration: none; }
.card p { margin: 4px 0 0; }

.product-card {
    position: relative; display: flex; flex-direction: column; overflow: hidden; background: var(--bg);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s;
}
.product-card:hover { box-shadow: var(--shadow-hover); border-color: var(--field-border); }   /* matte: no lift, a quiet edge */
@media (prefers-reduced-motion: reduce) { .product-card, .product-card:hover { transition: none; transform: none; } }
.product-card-media { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--photo-bg); border-bottom: 1px solid var(--line); }
.product-card-media > img:first-child { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 12px; }
.product-placeholder {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
}
.product-placeholder img { width: 34%; max-width: 130px; opacity: .9; }
.card-logo { position: absolute; top: 10px; left: 10px; width: 34px; height: auto; padding: 4px; background: var(--photo-bg); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.product-card-body { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px 16px; flex: 1; }
.product-card-category { margin: 0; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.product-card-title { margin: 0; font-size: 1.08rem; }
.product-card-title a { color: var(--ink); text-decoration: none; }
.product-card-title a::after { content: ""; position: absolute; inset: 0; } /* whole card clickable */
.product-card-title a:hover { color: var(--link); }
.product-card-summary { margin: 0; color: var(--ink-soft); font-size: .95rem; }
.product-card-price { margin: auto 0 0; padding-top: 8px; }

.category-tile { position: relative; display: flex; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); box-shadow: var(--shadow); transition: box-shadow .2s; }
.category-tile:hover { box-shadow: var(--shadow-hover); }
.category-tile-media { flex: 0 0 72px; height: 72px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.category-tile-media img { width: 100%; height: 100%; object-fit: contain; }
.category-tile-media img.logo { width: 46px; height: auto; }
.category-tile h3 { margin: 0; }
.category-tile h3 a { color: var(--ink); text-decoration: none; }
.category-tile h3 a::after { content: ""; position: absolute; inset: 0; }
.category-tile p { margin: 2px 0 0; font-size: .9rem; color: var(--muted); }

.features { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .features { grid-template-columns: repeat(3, 1fr); } }
.features li { padding: 18px; border-radius: var(--radius); background: var(--surface); border-left: 4px solid var(--brand); }
.features h3 { margin-bottom: 4px; }
.features p { margin: 0; color: var(--ink-soft); }

.cta { margin-top: 32px; padding: 24px; border-radius: var(--radius); background: var(--brand-tint); border: 1px solid var(--brand-line); }
.cta h2 { margin-top: 0; }

/* ---------- Product page ---------- */
.product-layout { display: grid; gap: 28px; margin-bottom: 8px; }
@media (min-width: 900px) { .product-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }
.gallery { position: sticky; top: 96px; }
.gallery-main { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--photo-bg); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.gallery-main img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 16px; }
.gallery-thumbs { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 10px 0 0; padding: 0; }
.gallery-thumbs a { display: block; width: 76px; height: 57px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--photo-bg); overflow: hidden; }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
@media (max-width: 899px) { .gallery { position: static; } }
.product-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

/* ---------- Filters, forms ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 16px 0 24px; padding: 12px; background: var(--surface); border-radius: var(--radius); }
.filters label { font-weight: 600; font-size: .9rem; }
.filters input, .filters select, .filters button { font: inherit; padding: 8px 10px; border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--bg); }
.filters input { flex: 1 1 200px; }
.filters button { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; cursor: pointer; }

.narrow { max-width: 680px; }
.form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px 6px; margin: 0 0 20px; background: var(--bg); }
.form legend { font-weight: 800; padding: 0 6px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
    width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--bg); color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field [aria-invalid=true] { border-color: #b3261e; }
.field.checkbox { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.field.checkbox label { font-weight: 400; margin: 0; flex: 1; }
.field.checkbox input { margin-top: 5px; accent-color: var(--brand); }
.field.checkbox .error { flex-basis: 100%; }
.hint { margin: 0 0 4px; font-size: .9rem; color: var(--muted); }
.error { margin: 4px 0 0; font-size: .9rem; color: #b3261e; font-weight: 600; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.notice { background: var(--surface); border-left: 4px solid var(--brand); padding: 12px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 0 0 16px; }
.notice p { margin: 0 0 6px; }
.notice p:last-child { margin: 0; }
.how-to-order .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.notice.warning { background: var(--warn-bg); border-left-color: var(--warn-ink); color: var(--warn-ink); }

.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 20px 0; }
.details dt { font-weight: 700; }
.details dd { margin: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
thead th { background: var(--surface); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); }
td code { white-space: nowrap; }

/* ---------- Cart & checkout ---------- */
.add-to-cart, .qty-form { display: flex; gap: 6px; align-items: center; }
.add-to-cart input, .qty-form input { width: 5em; font: inherit; padding: 6px 8px; border: 1px solid var(--field-border); border-radius: var(--radius-sm); }
.totals { font-size: 1.15rem; font-weight: 700; }
.steps { color: var(--muted); }

/* ---------- Content pages ---------- */
.content-layout { display: grid; gap: 28px; }
@media (min-width: 900px) { .content-layout { grid-template-columns: 240px 1fr; } }
.side-nav a { display: block; padding: 6px 0; text-decoration: none; }
.side-nav a[aria-current=page] { font-weight: 800; color: var(--ink); }
.prose { max-width: 72ch; }
.prose blockquote { margin: 16px 0; padding: 10px 14px; background: var(--warn-bg); border-left: 4px solid var(--warn-ink); color: var(--warn-ink); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { margin: 4px 0; }

/* ---------- Account security ---------- */
.codes { columns: 2; list-style: none; padding: 0; }
.setup-key code { font-size: 1.3rem; letter-spacing: .08em; }
.inline-form { display: inline-block; margin-right: 12px; }
section + section { margin-top: 28px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; padding: 0; margin: 20px 0; }
.pagination li > * { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; }
.pagination .active > * { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.pagination .disabled > * { color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { margin-top: 24px; padding-block: 32px 20px; background: var(--footer-bg); color: var(--footer-ink); font-size: .92rem; }
.site-footer a { color: var(--footer-ink); }
.site-footer .muted { color: var(--footer-muted); }
.footer-brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--footer-ink); }
.footer-brand img { width: 40px; height: auto; }
.footer-grid { display: grid; gap: 22px; margin-bottom: 18px; }
@media (min-width: 760px) { .footer-grid { grid-template-columns: 1.3fr 1fr 1fr; } }
.social { display: flex; flex-wrap: wrap; gap: 14px; }

/* ---------- Cookie banner ---------- */
.cookie-banner {
    position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 40; background: var(--bg); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-hover);
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
}
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0; flex: 1 1 280px; }

/* Error pages */
.error-page { max-width: 560px; margin: 64px auto; text-align: center; }
.error-page img { width: 120px; height: auto; margin: 0 auto 16px; }
.error-code { margin: 0; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--link); }

/* Cart: order online / request a quote */
.cart-actions { display: grid; gap: 16px; margin-top: 18px; }
@media (min-width: 760px) { .cart-actions { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); } }
.cart-action { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.cart-action h2 { margin: 0 0 6px; font-size: 1.1rem; }

/* Product options: stacked cards on small screens so quantity + Add are always visible */
@media (max-width: 720px) {
  .variant-wrap { overflow: visible; border: 0; background: none; }
  .variant-table, .variant-table tbody, .variant-table tr, .variant-table td { display: block; width: 100%; }
  .variant-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .variant-table tr { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 10px 14px; margin-bottom: 12px; }
  .variant-table td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 0; text-align: right; }
  .variant-table td::before { content: attr(data-label); font-weight: 600; text-align: left; color: var(--muted); }
  .variant-table .tiers { text-align: right; }
  .variant-table td.variant-add { display: block; padding-top: 10px; }
  .variant-table td.variant-add::before { content: none; }
  .variant-table .add-to-cart { display: flex; gap: 8px; }
  .variant-table .add-to-cart input { flex: 0 0 96px; }
  .variant-table .add-to-cart button { flex: 1; }
}
