:root {
  /* Brand + text */
  --ink: #0f1d1a;
  --muted: #344744;
  --accent: #0b6f5c;
  --accent-2: #e07a5f;

  /* Status */
  --danger: #dc3545;
  --success: var(--accent);

  /* Surfaces */
  --surface: rgba(255, 255, 255, 0.85);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-soft: rgba(255, 255, 255, 0.7);

  /* Lines */
  --border: rgba(15, 29, 26, 0.08);
  --border-mid: rgba(15, 29, 26, 0.12);
  --border-strong: rgba(15, 29, 26, 0.16);

  /* Radius scale */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* Elevation scale */
  --elev-1: 0 8px 18px rgba(15, 29, 26, 0.08);
  --elev-2: 0 12px 30px rgba(15, 29, 26, 0.12);
  --elev-3: 0 24px 60px rgba(15, 29, 26, 0.16);
  --shadow: var(--elev-3);

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Type scale */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-base: 16px;
  --text-lg: 20px;
  --text-xl: 32px;

  /* Layout */
  --page-gutter: 32px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: linear-gradient(140deg, #f7efe5 0%, #e5f4f7 55%, #f9f5e9 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

.page {
  min-height: 100vh;
  padding: 40px var(--page-gutter) 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: relative;
  overflow: clip;
}

.page > * {
  position: relative;
  z-index: 1;
}

.page::before,
.page::after {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle at top, rgba(11, 111, 92, 0.2), transparent 70%);
  pointer-events: none;
}

.page::before {
  top: -180px;
  right: -140px;
}

.page::after {
  bottom: -220px;
  left: -160px;
  background: radial-gradient(circle at top, rgba(224, 122, 95, 0.22), transparent 70%);
}

/* --------------------------- card + content --------------------------- */
.card {
  width: min(680px, 100%);
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 20px;
  /* In the flex-column page, auto margins center the card both ways and push
     the footer to the bottom. */
  margin: auto;
}

.brand {
  display: grid;
  gap: 6px;
}

.brand-mark {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--ink);
}

.brand-subtitle {
  font-size: 15px;
  color: var(--muted);
}

/* ------------------------------- forms -------------------------------- */
.form {
  display: grid;
  gap: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.field input,
.field select {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 15px;
  min-height: 46px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.field select {
  width: 100%;
  padding-right: 40px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6L8 10L12 6' stroke='%23344744' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 111, 92, 0.15);
}

/* ------------------------------ buttons ------------------------------- */
.button {
  border: none;
  border-radius: var(--radius-pill);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px rgba(11, 111, 92, 0.28);
}

.button:hover {
  transform: translateY(-2px);
}

.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
  box-shadow: none;
}

.button.secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid rgba(11, 111, 92, 0.2);
  box-shadow: none;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 100%;
}

/* ------------------------------- modal -------------------------------- */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow);
  width: min(680px, 90%);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--ink);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s ease;
}

.modal-close:hover {
  color: var(--ink);
}

/* -------------------------- status + helpers -------------------------- */
.status {
  min-height: 18px;
  font-size: 13px;
  margin: 0;
}

.status[data-state="error"] {
  color: var(--danger);
}

.status[data-state="success"] {
  color: var(--accent);
}

.footnote {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.dashboard {
  display: grid;
  gap: 14px;
}

.meta {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

/* Example national address block */
.address-example {
  background: rgba(11, 111, 92, 0.04);
  border: 1px solid rgba(11, 111, 92, 0.08);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--muted);
}

.address-example h3 {
  margin: 0 0 8px 0;
  font-size: 15px;
  color: var(--ink);
}

.address-example ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.address-example li strong {
  color: var(--ink);
  width: 120px;
  display: inline-block;
}

.address-example.hidden {
  display: none;
}

/* ------------------------------ footer -------------------------------- */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

/* =====================================================================
   Orders (src/orders.js)
===================================================================== */
.orders-list {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.order-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.order-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  list-style: none;
}

.order-head::-webkit-details-marker { display: none; }

.order-id {
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: var(--text-sm);
}

.order-date {
  color: var(--muted);
  font-size: var(--text-xs);
}

.order-status {
  margin-left: auto;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--border);
  color: var(--muted);
  text-transform: capitalize;
}

.order-status.is-shipped,
.order-status.is-delivered,
.order-status.is-purchased {
  background: rgba(11, 111, 92, 0.14);
  color: var(--accent);
}

.order-status.is-cancelled {
  background: rgba(220, 53, 69, 0.14);
  color: var(--danger);
}

.order-status.is-on_hold {
  background: rgba(224, 122, 95, 0.18);
  color: var(--accent-2);
}

.order-total {
  font-weight: 600;
  white-space: nowrap;
}

.order-body {
  padding: 0 var(--space-4) var(--space-4);
  display: grid;
  gap: var(--space-4);
}

.order-section-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 var(--space-2);
}

.order-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-sm);
}

.order-timeline li {
  display: flex;
  gap: var(--space-3);
  color: var(--muted);
}

.order-timeline .t-status {
  color: var(--ink);
  text-transform: capitalize;
  min-width: 96px;
}

.order-address {
  font-size: var(--text-sm);
  display: grid;
  gap: 2px;
}

.order-tracking { font-size: var(--text-sm); }

.order-store {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}

.order-store h4 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-md);
}

.order-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.order-item {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.order-item .oi-title { flex: 1; min-width: 0; }
.order-item .oi-side { white-space: nowrap; color: var(--muted); }

/* Order tracking step map */
.order-tracker {
  display: flex;
  margin: 2px 0 4px;
}

.ot-step {
  flex: 1;
  text-align: center;
  position: relative;
  font-size: 11px;
  color: var(--muted);
}

.ot-step::before {
  content: "";
  position: absolute;
  top: 6px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--border-mid);
  z-index: 0;
}

.ot-step:first-child::before { display: none; }

.ot-dot {
  position: relative;
  z-index: 1;
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border-mid);
  margin-bottom: 6px;
}

.ot-step.is-done .ot-dot,
.ot-step.is-current .ot-dot { background: var(--accent); }

.ot-step.is-done::before,
.ot-step.is-current::before { background: var(--accent); }

.ot-step.is-current .ot-dot {
  box-shadow: 0 0 0 3px rgba(11, 111, 92, 0.18);
}

.ot-step.is-current .ot-label {
  color: var(--ink);
  font-weight: 600;
}

.ot-label { display: block; }

.order-state-note {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.order-state-note.is-cancelled { color: var(--danger); }
.order-state-note.is-on_hold { color: var(--accent-2); }

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =====================================================================
   Site navigation (rendered by src/nav.js) — app-site's own copy
===================================================================== */
.sk-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  margin: -8px calc(-1 * var(--page-gutter)) 0;
  padding: 10px var(--page-gutter);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.sk-nav.is-scrolled {
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(15, 29, 26, 0.1);
}

.sk-nav-inner {
  display: flex;
  align-items: center;
  gap: 24px;
}

.sk-nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.sk-nav-logo img {
  width: 32px;
  height: 32px;
}

.sk-nav-menu {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: 1;
}

.sk-nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sk-nav-item {
  position: relative;
  display: flex;
  align-items: center;
}

.sk-nav-link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.sk-nav-link:hover {
  color: var(--ink);
  background: rgba(15, 29, 26, 0.05);
}

.sk-nav-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 36px;
  margin-left: -6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.sk-nav-caret svg {
  transition: transform 0.2s ease;
}

.sk-nav-item.has-menu:hover .sk-nav-caret svg,
.sk-nav-item:focus-within .sk-nav-caret svg {
  transform: rotate(180deg);
}

/* Dropdown panel */
.sk-nav-submenu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 18px 40px rgba(15, 29, 26, 0.14);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 10;
}

.sk-nav-item.has-menu .sk-nav-submenu {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.sk-nav-item.has-menu:hover .sk-nav-submenu,
.sk-nav-item.is-open .sk-nav-submenu,
.sk-nav-user.is-open .sk-nav-submenu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sk-nav-user .sk-nav-submenu {
  left: auto;
  right: 0;
}

.sk-nav-sublink {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.sk-nav-sublink:hover,
.sk-nav-sublink:focus-visible {
  background: rgba(11, 111, 92, 0.1);
  color: var(--accent);
}

/* Right-side actions */
.sk-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.sk-nav-cart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
}

.sk-nav-cart:hover {
  background: rgba(15, 29, 26, 0.05);
}

/* The inline cart shows on desktop (left of auth); the bar cart shows on
   mobile (next to the hamburger). */
.sk-nav-cart--bar {
  display: none;
}

.sk-nav-cart-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--accent-2);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.sk-nav-auth {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sk-btn {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.sk-btn-ghost {
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--border-mid);
}

.sk-btn-primary {
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
}

.sk-btn:hover {
  filter: brightness(0.97);
}

/* User menu */
.sk-nav-user {
  position: relative;
}

.sk-nav-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px 0 6px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.sk-nav-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
}

/* Keyboard focus visibility */
.sk-nav-link:focus-visible,
.sk-nav-caret:focus-visible,
.sk-nav-cart:focus-visible,
.sk-nav-sublink:focus-visible,
.sk-btn:focus-visible,
.sk-nav-user-btn:focus-visible,
.sk-nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Hamburger (hidden on desktop) */
.sk-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 38px;
  margin-left: auto;
  padding: 0 9px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  cursor: pointer;
}

.sk-nav-toggle span {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
}

/* Overlay close button (mobile only) */
.sk-nav-close {
  display: none;
  align-self: flex-end;
  width: 36px;
  height: 36px;
  margin: -4px -4px 4px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

body.sk-nav-scroll-lock {
  overflow: hidden;
}

/* ---------------------------- mobile ---------------------------- */
@media (max-width: 860px) {
  .sk-nav-toggle {
    display: flex;
  }

  .sk-nav-close {
    display: block;
  }

  /* On mobile only the bar cart shows, pushed next to the hamburger. */
  .sk-nav-cart--bar {
    display: inline-flex;
    margin-left: auto;
  }

  .sk-nav-cart--inline {
    display: none;
  }

  /* Full-screen overlay menu. */
  .sk-nav-menu {
    position: fixed;
    inset: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    max-width: none;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
    background: #fff;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  }

  .sk-nav-menu.is-open {
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  .sk-nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
  }

  .sk-nav-item {
    flex-wrap: wrap;
  }

  .sk-nav-link {
    flex: 1;
    height: 42px;
  }

  /* Text link navigates; the rest of the row (the caret) expands the submenu. */
  .sk-nav-item.has-menu .sk-nav-link {
    flex: 0 1 auto;
  }

  .sk-nav-item.has-menu .sk-nav-caret {
    flex: 1;
    height: 42px;
    margin-left: 0;
    padding-right: 4px;
    justify-content: flex-end;
  }

  /* Submenus expand inline (no hover on touch). */
  .sk-nav-submenu {
    position: static;
    width: 100%;
    margin: 2px 0 4px;
    box-shadow: none;
    border: 0;
    background: rgba(15, 29, 26, 0.03);
    opacity: 1;
    visibility: hidden;
    transform: none;
    display: none;
  }

  .sk-nav-item.is-open .sk-nav-submenu,
  .sk-nav-user.is-open .sk-nav-submenu {
    visibility: visible;
    display: block;
  }

  /* Rotation follows tap (.is-open) only — never hover/focus on touch. */
  .sk-nav-item.is-open .sk-nav-caret svg {
    transform: rotate(180deg);
  }

  .sk-nav-item.has-menu:not(.is-open):hover .sk-nav-caret svg,
  .sk-nav-item.has-menu:not(.is-open):focus-within .sk-nav-caret svg {
    transform: none;
  }

  .sk-nav-item.has-menu:hover .sk-nav-submenu {
    display: none;
  }

  .sk-nav-item.has-menu.is-open:hover .sk-nav-submenu {
    display: block;
  }

  /* Auth actions pinned to the bottom, full-width, stacked (Login on top). */
  .sk-nav-actions {
    margin-left: 0;
    margin-top: auto;
    padding-top: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .sk-nav-auth {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }

  .sk-btn {
    width: 100%;
    justify-content: center;
  }

  /* Logged-in menu opens upward (it sits at the bottom) without moving the button. */
  .sk-nav-user .sk-nav-submenu {
    position: absolute;
    top: auto;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 18px 40px rgba(15, 29, 26, 0.14);
  }
}

/* =====================================================================
   Accessibility: honor reduced-motion preference
===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
