/* core/public/css/site.css — site-wide layout + components for Phase 1A catalog.
 * Consumes brand custom properties from /css/brand/theme.css.
 * No build step; plain CSS.
 */

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-ink, #1a1a1a);
  background: var(--color-neutral, #fff);
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-primary-dark, var(--color-primary, #06c)); text-underline-offset: 0.15em; }
a:hover { color: var(--color-primary, #06c); }

/* === Typography === */
h1, h2, h3, h4 {
  font-family: var(--font-heading, var(--font-body, serif));
  line-height: 1.2;
  margin: 0 0 0.5em;
  color: var(--color-ink, #1a1a1a);
}
h1 { font-size: 2.25rem; letter-spacing: -0.01em; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1rem; }
.text-muted { color: var(--color-muted, #666); }

/* === Layout === */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 2rem; }

.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius, 8px);
  font-weight: 600;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s ease;
  font-family: inherit;
  font-size: 1rem;
}
.btn-primary {
  background: var(--color-primary, #06c);
  color: var(--color-neutral, #fff);
  border-color: var(--color-primary, #06c);
}
.btn-primary:hover { opacity: 0.9; color: var(--color-neutral, #fff); }
.btn-secondary {
  background: transparent;
  color: var(--color-primary-dark, var(--color-primary, #06c));
  border-color: var(--color-primary-dark, var(--color-primary, #06c));
}
.btn-secondary:hover { background: var(--color-primary-dark, var(--color-primary, #06c)); color: var(--color-neutral, #fff); }
.btn-disabled, .btn:disabled {
  background: var(--color-muted, #999);
  color: var(--color-neutral, #fff);
  border-color: var(--color-muted, #999);
  cursor: not-allowed;
  opacity: 0.65;
}

/* === Cards === */
.card {
  background: #fff;
  border-radius: var(--radius, 8px);
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
a.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.08); }
.card-image { aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius, 8px); margin: -1.25rem -1.25rem 1rem; background: var(--color-neutral, #f4f4f4); }
.card-image img { width: 100%; height: 100%; object-fit: cover; }
.card-title { font-size: 1.125rem; margin: 0 0 0.25rem; }
.card-meta { font-size: 0.875rem; color: var(--color-muted, #666); margin: 0 0 0.5rem; }
.card-price { margin-top: auto; padding-top: 0.75rem; font-weight: 600; color: var(--color-primary-dark, var(--color-primary, #06c)); }

/* === Header / Footer (overrides Phase 0 placeholder vibe) === */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: var(--color-neutral, #fff);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  max-width: 1200px;
  margin: 0 auto;
}
.brand-logo img { max-height: 48px; width: auto; }
.site-header nav { display: flex; gap: 1.5rem; flex-wrap: wrap; }

/* The header had no responsive rules at all: six nav links in a nowrap flex row
   ran past the right edge at phone width, so the whole page scrolled sideways
   and the Cart link sat off-screen. Below 640px the nav wraps onto its own line
   under the wordmark. */
@media (max-width: 640px) {
  .site-header {
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    padding: 1rem 1.25rem;
  }
  .site-header nav {
    width: 100%;
    gap: 0.75rem 1rem;
    font-size: 0.9375rem;
  }
  .brand-logo img { max-height: 36px; }
}
.nav-link { color: var(--color-ink, #1a1a1a); text-decoration: none; font-weight: 500; }
.nav-link:hover { color: var(--color-primary, #06c); }
/* Signed-in header items. The header sits on the brand's dark band, so the
   greeting and the sign-out button must take the band's foreground colour —
   .link-button's own link colour is unreadable against it. */
.site-header .header-greeting { font-weight: 500; }
.site-header .inline-form { display: inline; }
.site-header .link-button {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
  font-size: inherit;
}
.site-header .link-button:hover { color: var(--color-primary, #06c); opacity: 1; }
.site-footer {
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-muted, #666);
  border-top: 1px solid rgba(0,0,0,0.06);
  margin-top: 4rem;
}

/* === Breadcrumbs === */
.breadcrumbs { font-size: 0.875rem; color: var(--color-muted, #666); margin: 1.5rem 0; }
.breadcrumbs a { color: inherit; }
.breadcrumbs > * + *::before { content: "›"; margin: 0 0.5rem; }

/* === Hero / category banner === */
.hero-banner {
  padding: 3rem 0;
  text-align: center;
}
.hero-banner h1 { margin-bottom: 0.5rem; }
.hero-banner .lede { font-size: 1.125rem; max-width: 60ch; margin: 0 auto; color: var(--color-muted, #666); }

/* === Tier table === */
.tier-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  background: #fff;
  border-radius: var(--radius, 8px);
  overflow: hidden;
}
.tier-table th, .tier-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.tier-table th { background: var(--color-neutral, #f8f8f8); font-weight: 600; font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-muted, #666); }
.tier-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tier-table tr:last-child td { border-bottom: 0; }
.tier-table .tier-default { background: rgba(0,0,0,0.02); font-weight: 600; }

/* === Product detail === */
.product-detail { display: grid; gap: 2rem; grid-template-columns: 1fr; }
.product-image { aspect-ratio: 1 / 1; background: var(--color-neutral, #f4f4f4); border-radius: var(--radius, 8px); overflow: hidden; }
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.product-summary p.lede { font-size: 1.125rem; color: var(--color-muted, #666); }
.product-cta { margin-top: 1.5rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.product-cta input[type="number"] {
  width: 100px;
  padding: 0.75rem;
  font-size: 1rem;
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: var(--radius, 8px);
  font-family: inherit;
}
.cta-note { font-size: 0.875rem; color: var(--color-muted, #666); margin-top: 0.5rem; flex-basis: 100%; }

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--color-muted, #666);
}

/* === Error pages === */
.error-page { padding: 4rem 0; text-align: center; }
.error-page h1 { font-size: 2.5rem; }
.error-page .error-detail { color: var(--color-muted, #666); margin-bottom: 2rem; }
.error-trace { background: rgba(0,0,0,0.04); padding: 1rem; border-radius: var(--radius, 8px); text-align: left; font-size: 0.875rem; overflow-x: auto; }

/* === Forms ===
   Storefront inputs. Without these, every form on the site rendered at the
   browser default: fields shrink-wrapped to their default width, sitting inline
   against the left edge of the viewport with no container. */
.stack-sm > * + * { margin-top: 0.5rem; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 0.25rem;
}
label.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}
label.checkbox input { width: auto; margin: 0; }

input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="number"], input[type="search"],
select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: var(--radius, 8px);
  font: inherit;
  font-weight: 400;
  color: inherit;
  background: #fff;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--color-primary, #06c);
  outline-offset: 1px;
  border-color: transparent;
}

/* === Auth pages ===
   Sign in, register, password reset. A narrow single column: these forms ask
   for two fields and should not stretch to a 1200px container. */
.auth-page {
  max-width: 26rem;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}
.auth-page h1 { font-size: 1.75rem; margin-bottom: 1.5rem; }
.auth-form > * + * { margin-top: 1rem; }
.auth-form button[type="submit"] { width: 100%; margin-top: 1.5rem; }
.auth-links {
  margin-top: 1.5rem;
  font-size: 0.9375rem;
  color: var(--color-muted, #666);
}

/* === Account area === */
.account-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: grid;
  gap: 2rem;
}
.account-nav {
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  font-weight: 600;
  font-size: 0.9375rem;
}
/* The nav is a <ul>, so the list marker has to go explicitly — without this it
   renders as a bulleted list down the side of the account area. */
.account-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
}
.account-nav .inline-form { display: inline; }
.account-nav a { text-decoration: none; color: var(--color-muted, #666); }
.account-nav a:hover, .account-nav a[aria-current="page"] {
  color: var(--color-primary-dark, var(--color-primary, #06c));
}
.account-main > h1 { font-size: 1.75rem; }
.account-cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  margin-top: 1.5rem;
}
.account-cards .card h2 { font-size: 1.125rem; margin: 0 0 0.25rem; }
.account-cards .card p { margin: 0; color: var(--color-muted, #666); font-size: 0.9375rem; }
.account-main form { max-width: 32rem; }

/* === Orders ===
   Shared by the order confirmation and the account order history, so a buyer
   sees the same summary in both places. */
.order-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 0;
}
.order-line-total {
  padding-top: 0.75rem;
  border-top: 1px solid rgba(0,0,0,0.1);
  font-size: 1.0625rem;
}
.order-totals { padding-top: 0.75rem; border-top: 1px solid rgba(0,0,0,0.1); }
.order-status {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary-dark, var(--color-primary, #06c));
  white-space: nowrap;
}
.order-history-item header { padding-bottom: 0.75rem; border-bottom: 1px solid rgba(0,0,0,0.08); }
.address { margin: 0; line-height: 1.7; }

/* === Order confirmation === */
.checkout-success { padding-top: 2.5rem; }
.checkout-success-head { text-align: center; max-width: 34rem; margin: 0 auto; }
.checkout-success-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--color-primary, #06c);
  color: var(--color-neutral, #fff);
  font-size: 1.75rem;
  line-height: 1;
}
.checkout-success .card { max-width: 34rem; margin-left: auto; margin-right: auto; }
.checkout-success .cart-actions { justify-content: center; }

@media (min-width: 768px) {
  .account-page { grid-template-columns: 12rem 1fr; align-items: start; }
  .account-nav {
    padding-bottom: 0;
    padding-right: 1.5rem;
    border-bottom: 0;
    border-right: 1px solid rgba(0,0,0,0.1);
  }
  .account-nav ul { flex-direction: column; gap: 0.75rem; }
}

/* A button that has to read as a link: "Set as default" and "Remove" sit inside
   an address card, where a full button would outweigh the address itself. */
.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-primary-dark, var(--color-primary, #06c));
  text-decoration: underline;
  cursor: pointer;
}
.link-button.danger { color: #a3271e; }
.link-button:hover { opacity: 0.8; }

/* === Cart ===
   None of this existed. The cart page only looks wrong once it has something in
   it, so an empty-cart check said it was fine: the line image ran the full width
   of the column, the quantity field stretched beside it, and Update and Remove
   stacked underneath. */
.cart-lines { margin-top: 1.5rem; }
.cart-line {
  display: grid;
  grid-template-columns: 5rem 1fr auto;
  gap: 1rem;
  align-items: start;
  padding: 1.25rem 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.cart-line-image {
  width: 5rem;
  aspect-ratio: 1;
  border-radius: var(--radius, 8px);
  overflow: hidden;
  background: rgba(0,0,0,0.03);
}
.cart-line-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cart-line-name { font-size: 1rem; margin: 0 0 0.125rem; }
.cart-line-name a { color: inherit; text-decoration: none; }
.cart-line-name a:hover { text-decoration: underline; }
.cart-line-variant { font-size: 0.875rem; margin: 0 0 0.75rem; }
.cart-line-info { display: flex; flex-direction: column; align-items: flex-start; }
.cart-line-update {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.cart-line-update label { margin-bottom: 0; font-size: 0.8125rem; }
/* A quantity is three or four digits — the global full-width input rule would
   stretch it across the line. */
.cart-line-update input[type="number"] { width: 6rem; margin-top: 0.125rem; }
.cart-line-update .btn { padding: 0.5rem 1rem; font-size: 0.875rem; }
.cart-line-total { font-size: 1.0625rem; white-space: nowrap; padding-top: 0.125rem; }

.cart-summary {
  margin-top: 1.5rem;
  margin-left: auto;
  max-width: 22rem;
  text-align: right;
}
.cart-totals { margin: 0 0 0.25rem; font-size: 0.875rem; }
.cart-subtotal-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 1.125rem;
  margin: 0 0 0.5rem;
}
.cart-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

@media (max-width: 560px) {
  .cart-line { grid-template-columns: 4rem 1fr; }
  .cart-line-image { width: 4rem; }
  .cart-line-total { grid-column: 2; text-align: right; }
  .cart-actions { justify-content: stretch; }
  .cart-actions .btn { flex: 1; text-align: center; }
}

/* === Responsive === */
@media (min-width: 768px) {
  h1 { font-size: 3rem; }
  .product-detail { grid-template-columns: 1fr 1fr; gap: 3rem; }
  .product-image { aspect-ratio: 4 / 5; }
}
