/* Aether 2030 — Premium Static Commerce Experience
   Self-contained, no external dependencies.
   Mobile-first, dark, WCAG AA, micro-animations, high-end feel.
*/

:root {
  /* 2030 premium dark palette */
  --bg: #050505;
  --bg-elev: #0a0a0c;
  --surface: #111114;
  --surface-2: #16161a;
  --surface-3: #1f1f24;
  --text: #f1f1f3;
  --text-muted: #a1a1a7;
  --text-subtle: #6f6f76;
  --accent: #7c8cff;
  --accent-2: #a5b4fc;
  --gold: #c5a26f;
  --success: #22c55e;
  --warning: #facc15;
  --danger: #f87171;
  --border: #27272b;
  --focus: #7c8cff;

  /* Motion */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 360ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Layout */
  --maxw: 1280px;
  --gutter: 24px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 1ms;
    --dur-base: 1ms;
    --dur-slow: 1ms;
  }
}

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Typography */
h1, h2, h3, h4 { font-weight: 600; line-height: 1.1; margin: 0 0 .5em; }
h1 { font-size: clamp(28px, 5vw, 44px); letter-spacing: -.02em; }
h2 { font-size: clamp(22px, 3.5vw, 28px); }
h3 { font-size: 18px; }
p { margin: 0 0 1em; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--text-subtle); }

button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast), border-color var(--dur-fast);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--surface-2); transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }
button:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent);
  color: #0a0a0c;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
}
.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
  color: var(--danger);
}
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

input, select, textarea {
  font: inherit;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input::placeholder { color: var(--text-subtle); }

label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

.field { margin-bottom: 14px; }
.field-inline { display: flex; gap: 12px; align-items: flex-end; }
.field-inline .field { flex: 1; margin-bottom: 0; }

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
  min-height: 1em;
}

/* Layout containers */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.section { padding: 56px 0; }
.section + .section { border-top: 1px solid var(--border); }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 32px; }
@media (min-width: 860px) {
  .grid-2 { grid-template-columns: 1.05fr 1fr; }
}
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  font-size: 15px;
}
.brand .mark {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  border-radius: 6px;
  display: inline-block;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.locale-switch, .currency-switch {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
}
.locale-switch button, .currency-switch button {
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
}
.locale-switch button[aria-pressed="true"],
.currency-switch button[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--text);
}

/* Product hero */
.product-hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
  align-items: start;
}
@media (min-width: 980px) {
  .product-hero { grid-template-columns: 1.1fr 1fr; }
}

.visual {
  position: relative;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#webgl-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#webgl-canvas:active { cursor: grabbing; }

.visual-fallback {
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  background: #0b0b0e;
}
.visual.show-fallback #webgl-canvas { display: none; }
.visual.show-fallback .visual-fallback { display: flex; }

.visual-controls {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.visual-controls button {
  font-size: 12px;
  padding: 6px 10px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border-color: color-mix(in srgb, var(--border) 70%, transparent);
  backdrop-filter: blur(6px);
}

.config-panel h2 { margin-bottom: 6px; }
.config-panel .lead {
  color: var(--text-muted);
  margin-bottom: 18px;
}

.option-group {
  margin-bottom: 18px;
}
.option-group legend {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.option {
  position: relative;
}
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  transition: border-color var(--dur-fast), background var(--dur-fast);
  cursor: pointer;
}
.option .chip .swatch {
  width: 16px; height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.15);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.3);
}
.option input:checked + .chip {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.option input:focus-visible + .chip {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}

.engraving-input {
  margin-top: 6px;
}
.engraving-input input {
  font-family: var(--font-mono);
  letter-spacing: 1.5px;
}

.price-block {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 18px 0;
}
.price-current {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -.02em;
}
.price-compare {
  color: var(--text-subtle);
  text-decoration: line-through;
  font-size: 15px;
}
.stock {
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.stock.in { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, var(--border)); }
.stock.low { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, var(--border)); }
.stock.out { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* Catalog & filters */
.catalog-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.search {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 340px;
}
.search input { padding-left: 36px; }
.search::before {
  content: "⌘";
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-size: 13px;
}
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-chip {
  font-size: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.filter-chip[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--accent);
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--dur-base) var(--ease), border-color var(--dur-base);
}
.product-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.product-card .thumb {
  aspect-ratio: 16 / 10;
  background: #0b0b0e;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.product-card .thumb img { width: 68%; height: auto; display: block; }
.product-card .meta {
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.product-card .title { font-weight: 600; }
.product-card .price { color: var(--text-muted); font-feature-settings: "tnum"; }
.product-card .rating { font-size: 13px; color: var(--text-subtle); }
.product-card .actions { padding: 0 14px 14px; }

/* Bundle */
.bundle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.bundle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.bundle-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.bundle-item {
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

/* Cart drawer */
#cart-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0,0,0,.6);
  z-index: 200;
  display: none;
  flex-direction: column;
}
#cart-drawer.open { display: flex; }
.cart-header {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cart-body { flex: 1; overflow: auto; padding: 12px 18px; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item .name { font-weight: 600; }
.cart-item .config { font-size: 12px; color: var(--text-subtle); }
.cart-item .price { font-feature-settings: "tnum"; white-space: nowrap; }
.cart-qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cart-qty button { padding: 2px 8px; }
.totals {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.totals-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 4px 0;
}
.totals-row.total { font-weight: 600; font-size: 16px; padding-top: 10px; border-top: 1px solid var(--border); margin-top: 6px; }

/* Coupon */
.coupon { display: flex; gap: 8px; margin: 12px 0; }
.coupon input { flex: 1; }
.coupon-feedback { font-size: 13px; min-height: 1em; }

/* Fit recommender */
.fit {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 16px 0;
}
.fit-output {
  margin-top: 8px;
  font-size: 14px;
}

/* Checkout */
.checkout-flow {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  display: none;
  overflow: auto;
}
.checkout-flow.open { display: block; }

.checkout-header {
  position: sticky; top: 0;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
.steps {
  display: flex;
  gap: 8px;
  padding: 14px var(--gutter);
  overflow-x: auto;
}
.step {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.step.active {
  background: var(--accent);
  color: #0a0a0c;
  border-color: var(--accent);
}

.checkout-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px var(--gutter) 80px;
}
.checkout-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}
@media (min-width: 860px) {
  .checkout-grid { grid-template-columns: 1.1fr .9fr; }
}

.order-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.order-summary h3 { margin-bottom: 12px; }
.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 6px 0;
}
.summary-line.total { font-weight: 700; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 6px; }

/* Confirmation */
.confirmation {
  max-width: 720px;
  margin: 40px auto;
  padding: 32px var(--gutter);
  text-align: center;
}
.confirmation .badge {
  display: inline-block;
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 35%, var(--border));
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  margin-bottom: 12px;
}
.confirmation .order-id {
  font-family: var(--font-mono);
  font-size: 21px;
  letter-spacing: 2px;
  margin: 8px 0 20px;
}

/* Assistant (Agentic Commerce) */
#assistant {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 250;
  width: min(380px, calc(100% - 40px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#assistant.collapsed .assistant-body,
#assistant.collapsed .assistant-input {
  display: none;
}
.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.assistant-header .title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.assistant-header .badge-ai {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #0a0a0c;
}
.assistant-body {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.step-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.step .dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 14px;
  margin-top: 2px;
}
.step.done .dot { background: var(--success); }
.step.error .dot { background: var(--danger); }
.step .text { flex: 1; }

.assistant-input {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
}
.assistant-input input {
  flex: 1;
  padding: 9px 12px;
}
.assistant-input button { padding: 9px 14px; }

.prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 12px;
}
.prompt-chip {
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
}
.prompt-chip:hover { border-color: var(--accent); }

/* Micro animations */
.fade-in { animation: fadeIn var(--dur-base) var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.price-update {
  animation: pricePop 320ms var(--ease);
}
@keyframes pricePop {
  0% { transform: scale(0.98); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

/* Accessibility & reduced motion */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Print styles for confirmation */
@media print {
  .site-header, .nav-actions, #assistant, .visual-controls, .btn, .filters { display: none !important; }
  .confirmation { box-shadow: none; }
}

/* High contrast focus */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Scrollbars (subtle) */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: #35353b; }