/*
 * Samchi storefront — minimal, fluid, accessible design system.
 * Loaded after site.css in base.html; overrides the semantic design tokens
 * and adds fluid entrance animations plus hover lifts.
 */

/* ---- Minimal palette (light + dark) ---- */
:root {
  /* Adapted from After40's warm stone and dark timber palette; Samchi red stays the brand cue. */
  --canvas: #f7f3eb;
  --surface: #fffdf8;
  --surface-strong: #f4efe6;
  --ink: #211d18;
  --muted: #6b6256;
  --border: #e7ddcd;
  --footer: #f3eee4;
  --primary: #d91c32;
  --on-primary: #fff;
  --primary-hover: #a60f25;
  --primary-soft: #fceef0;
  --focus: var(--primary);
  --radius: 16px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --shadow-card: 0 1px 2px rgba(20, 24, 32, .04), 0 6px 20px rgba(20, 24, 32, .06);
}
.dark {
  --canvas: #0e1017;
  --surface: #141822;
  --surface-strong: #1b2030;
  --ink: #f3f5fb;
  --muted: #b6c1ce;
  --border: #2a3045;
  --footer: #0c0f16;
  --primary: #ff8a99;
  --on-primary: #171a22;
  --primary-hover: #f3a2b2;
  --primary-soft: #2a1a1e;
  --focus: var(--primary);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .42), 0 6px 20px rgba(0, 0, 0, .5);
}

/* ---- Typography — clean Manrope scale, tighter headings ---- */
body {
  font-family: var(--font-sans);
  letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { letter-spacing: -.014em; }
h1 { line-height: 1.1; }
h2, h3 { line-height: 1.25; }

/* ---- Links — quiet by default, primary on hover ---- */
a { color: inherit; }
.sf-footer a { color: inherit; }
a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---- Buttons — larger targets, consistent, fluid ---- */
.button {
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  transition: color .18s, background-color .18s, box-shadow .2s, transform .18s;
}
.button:active { transform: translateY(1px); }
.button-primary {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16), 0 1px 2px rgba(0, 0, 0, .08);
}
.button-primary:hover, .dark .button-primary:hover { background: var(--primary-hover); }
.button-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}
.button-secondary:hover { border-color: var(--primary); }
.text-link { min-height: 44px; font-weight: 700; color: var(--primary); }

.sf-account-group-label {
  margin: .35rem .75rem .15rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 750;
}
.sf-account-links a[aria-current="page"] { background: var(--surface-strong); }

/* ---- Forms — consistent heights and radii ---- */
.public-form :is(input, select, textarea) {
  min-height: 44px;
  padding-block: 9px;
  border-radius: 10px;
}

/* ---- Cards — minimal surfaces, subtle depth, lift on hover ---- */
.catalog-card {
  background: var(--surface);
  border-color: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out);
}
.dark .catalog-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
}
.dark .catalog-card-media {
  background: #f1f3f6;
}
.dark .catalog-card-caption {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}
.catalog-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 34px rgba(20, 24, 32, .1);
}
.catalog-card:focus-visible { outline-offset: 4px; }
.catalog-card-media > span { inset-block-start: 18px; inset-block-end: 0; }
.catalog-card-caption {
  background: none;
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  gap: 12px;
}
.catalog-card-caption h3 { letter-spacing: -.012em; margin: 0 0 5px; font-size: 18px; line-height: 1.35; }
.catalog-card-caption p { color: var(--muted); margin: 0; font-size: 13px; }
.catalog-card-caption { color: var(--ink); }
.catalog-price { color: var(--primary); font-weight: 750; }
.catalog-views { color: var(--muted); }
.dark .catalog-card-caption,
.dark .catalog-card-caption h3,
.dark .catalog-card-caption p,
.dark .catalog-views,
.dark .branch-stock-note { color: var(--muted); }
.dark .catalog-card-caption h3 { color: var(--ink); }
.dark .catalog-card-caption .catalog-price { color: var(--primary); }
.catalog-card-caption > .icon { width: 28px; height: 28px; border: 0; padding: 6px; transform: none; }
.catalog-card-caption:hover > .icon { background: none; }
.catalog-badge {
  background: var(--primary-soft);
  border: 0;
  color: var(--primary);
  border-radius: 999px;
  font-size: 11px;
  padding: 5px 9px;
}
.catalog-card .image-placeholder { color: var(--muted); }
.catalog-card .image-placeholder .icon { width: 56px; height: 56px; }

/* ---- Grids — fluid columns ---- */
.catalog-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16.75rem), 1fr));
  align-items: stretch;
  justify-items: stretch;
  gap: 20px;
}
.catalog-grid > .catalog-card { width: 100%; min-width: 0; }
.catalog-grid > .catalog-card:nth-child(n) { grid-column: auto; }
.product-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }

.branch-products { margin-block-start: 2.5rem; }
.branch-products-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-block-end: 1rem;
}
.branch-products-heading h2 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.75rem); }
.branch-products-heading p { margin: .35rem 0 0; color: var(--muted); }
.branch-products-heading .branch-products-count { margin: 0; white-space: nowrap; font-size: .9rem; }
.branch-stock-note { display: block; margin-block-start: .3rem; color: var(--muted); font-size: .78rem; }
.branch-products-empty { grid-column: 1 / -1; }
.branch-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem; }
.branch-pagination a,
.branch-pagination > span:not(.pagination-ellipsis) {
  display: inline-flex;
  min-inline-size: 2.75rem;
  min-block-size: 2.75rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: .6rem;
  padding-inline: .7rem;
}
.branch-pagination a { color: var(--ink); text-decoration: none; }
.branch-pagination a:hover { border-color: var(--primary); color: var(--primary); }
.branch-pagination [aria-current="page"] { background: var(--surface-strong); border-color: var(--primary); font-weight: 750; }
.branch-pagination .pagination-ellipsis { padding-inline: .25rem; color: var(--muted); }

.order-store-group { margin-block: 1rem; }
.order-store-group h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 0; padding-block: .9rem; border-block-end: 1px solid var(--border); font-size: 1rem; }
.order-store-group h3 a { flex: none; font-size: .82rem; font-weight: 650; }
.order-store-group ul { margin: 0; padding: 0; list-style: none; }
.order-store-group li { display: flex; justify-content: space-between; gap: 1rem; padding-block: .8rem; border-block-end: 1px solid var(--border); }
.order-store-group li > span { min-inline-size: 0; overflow-wrap: anywhere; }
.order-store-group li > strong { flex: none; }
.order-store-subtotal { display: flex; justify-content: space-between; gap: 1rem; margin: 0; padding-block: .8rem; color: var(--muted); }
.order-store-subtotal strong { color: var(--ink); }

@media (max-width: 560px) {
  .branch-products-heading { align-items: start; flex-direction: column; gap: .35rem; }
  .branch-products-heading .branch-products-count { white-space: normal; }
}
@media (pointer: coarse) {
  .branch-pagination a,
  .branch-pagination > span:not(.pagination-ellipsis) { min-inline-size: 2.75rem; min-block-size: 2.75rem; }
}

/* ---- Sections — quieter rhythm ---- */
.sf-section { padding-block: 52px; }
.sf-section-heading { gap: 26px; margin-bottom: 30px; }
.sf-section-heading h2 { font-size: clamp(22px, 2.5vw, 30px); line-height: 1.2; }
.sf-section-heading p { font-size: 14px; line-height: 1.7; }
.page-heading h1 { letter-spacing: -.02em; }
.page-heading p { font-size: 14px; }

/* ---- Hero — entrance animation ---- */
.sf-hero { animation: arrive .85s var(--ease-out) both; }
.sf-hero-copy { animation: none; } /* copy-arrive plays in site.css */

/* ---- Footer — quieter, more air ---- */
.sf-footer { padding-block: 44px 20px; margin-top: 36px; }
.sf-footer h2 { font-size: 13px; }
.sf-footer p { font-size: 12.5px; }
.sf-footer a { min-height: 40px; font-size: 12.5px; }
.sf-footer-bottom { font-size: 11px; }

/* ---- Newsletter — card with fluid form ---- */
.sf-newsletter { border: 1px solid var(--border); background: var(--surface); }
.sf-newsletter .newsletter-form { flex-wrap: wrap; gap: 10px; }
.sf-newsletter h2 { font-size: 24px; }

/* ---- Branches page — minimal cards ---- */
.contact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; }
.contact-card h2 { margin-block-end: 8px; }
.branch-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 22px; }
.branch-card h3 a { color: var(--ink); }

/* ---- Product share — minimal copy UI ---- */
.product-share { border-top: 1px solid var(--border); margin-block-start: 26px; padding-top: 22px; }
.product-share__link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; min-height: 40px;
  border-radius: 10px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  transition: border-color .18s, background-color .18s;
}
.product-share__link:hover { border-color: var(--primary); }
.product-share__copy-row { display: flex; gap: 8px; margin-top: 14px; }
.product-share__url { min-height: 44px; border-radius: 10px; }
.product-share__copy-button { min-height: 44px; }
.product-share__status { min-height: 24px; }

/* ---- Filters + results ---- */
.sf-filters summary { font-size: 14px; min-height: 40px; }
.sf-filter-form { gap: 16px; }
.results-toolbar { font-size: 13px; }
.empty-state { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 48px 24px; }
.empty-state h2 { font-size: 18px; margin-block: 4px 8px; }
.pagination { padding-top: 26px; }
.pagination a { border-radius: 8px; padding: 8px 14px; }

/* ---- Bag page — quieter panels ---- */
.bag-panel { border-radius: 16px; box-shadow: var(--shadow-card); padding: 24px; }
.bag-panel-heading h2 { font-size: 19px; }
.bag-estimated-total strong { font-size: 22px; }

/* ---- Entrance animation ---- */
@keyframes arrive {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.sf-section, .catalog-grid, .product-grid, .sf-footer, .branch-grid, .review-section {
  animation: arrive .7s var(--ease-out) both;
}

/* ---- Loyalty redemption summary ---- */
.loyalty-discount-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-block: 1px solid var(--border);
  color: var(--primary);
  font-size: .95rem;
}
.loyalty-discount-line strong { font-weight: 700; }

/* ---- Respect reduced motion; keep content reachable ---- */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001s !important;
  }
  .catalog-card, .catalog-card:hover { transform: none !important; box-shadow: var(--shadow-card); }
  .catalog-card-caption > .icon { transform: none !important; }
  .catalog-card-media img { transition: none; }
  .sf-section, .catalog-grid, .product-grid, .sf-footer, .branch-grid, .review-section { animation: none; }
}

.sf-footer { padding-block-end: calc(4.75rem + env(safe-area-inset-bottom, 0px)); }
html { scroll-padding-block-end: calc(4.75rem + env(safe-area-inset-bottom, 0px)); }
