:root {
  /* from the East Coast Sailboats logo */
  --navy: #042d66;
  --sea: #1f6f8b;
  --accent: #df101d;
  --text: #1b2a3a;
  --muted: #5b6b7f;
  --border: #d9e0e8;
  --bg: #f5f7fa;
  --card: #ffffff;
  --warn-bg: #fff6e0;
  --warn-border: #f0c36d;
  --error: #b42318;
  --radius: 10px;
  --tap: 44px;
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--sea); }

h1 { font-size: 1.5rem; margin: 0 0 .75rem; color: var(--navy); }
h2 { color: var(--navy); }

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

.muted, .optional { color: var(--muted); font-weight: normal; }
.optional { font-size: .875em; }
.fine-print { color: var(--muted); font-size: .875rem; }

/* ---------- header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 16px;
  background: #fff;
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 1px 0 var(--navy);
}
.site-header .brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--navy); text-decoration: none; font-weight: 700; line-height: 1.2;
}
.site-header .brand img { display: block; height: 48px; width: auto; }
.site-header .brand span { font-size: .95rem; letter-spacing: .02em; }
.cart-link {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap); padding: 0 14px;
  background: var(--navy); color: #fff; text-decoration: none; font-weight: 600;
  border-radius: 999px;
}
.cart-count {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--accent); color: #fff; font-size: .8rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.cart-count[hidden] { display: none; }

/* ---------- controls ---------- */

button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 0 18px;
  border: 0; border-radius: 8px;
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
button:disabled, .button.disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: var(--card); color: var(--navy); border: 1px solid var(--border); }
.link-button {
  background: none; color: var(--sea); padding: 0 4px; min-height: var(--tap);
  font-weight: 500; text-decoration: underline; border: 0; cursor: pointer;
  display: inline-flex; align-items: center;
}

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
  font: inherit; font-size: 16px; /* prevents iOS zoom on focus */
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(31,111,139,.35); outline-offset: 1px;
}
[aria-invalid="true"] { border-color: var(--error); }

label { display: block; margin-bottom: 12px; font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 4px; }
label.checkbox, label.radio { display: flex; align-items: center; gap: 10px; min-height: var(--tap); margin-bottom: 4px; }
label.checkbox input, label.radio input { width: 20px; height: 20px; min-height: 0; margin: 0; }

fieldset { border: 0; padding: 0; margin: 0 0 20px; }
legend { font-weight: 700; color: var(--navy); margin-bottom: 8px; padding: 0; }

.field-error { display: block; color: var(--error); font-size: .875rem; margin-top: 4px; font-weight: 500; }

.notice { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; background: #eef3f9; }
.notice-warn { background: var(--warn-bg); border: 1px solid var(--warn-border); }
.notice ul { margin: 0; padding-left: 18px; }

/* ---------- search ---------- */

.search-layout { padding: 16px; max-width: 1200px; margin: 0 auto; }

.search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-bar input { margin: 0; }

.audience-toggle { display: flex; gap: 0; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.audience-toggle button { flex: 1; border-radius: 0; background: #fff; color: var(--navy); font-weight: 500; }
.audience-toggle button + button { border-left: 1px solid var(--border); }
.audience-toggle button[aria-pressed="true"] { background: var(--navy); color: #fff; }

.filters { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.filters summary { padding: 12px 14px; min-height: var(--tap); font-weight: 600; cursor: pointer; color: var(--navy); }
.filter-count { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 10px; background: var(--sea); color: #fff; font-size: .8rem; }
.filter-count[hidden] { display: none; }
.filters-body { padding: 0 14px 14px; }
.price-range { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.price-range legend { font-weight: 500; color: var(--text); margin-bottom: 4px; }
.price-range label { flex: 1; margin: 0; }

.result-count { color: var(--muted); margin: 0 0 12px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid[aria-busy="true"] { opacity: .5; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.card-img { aspect-ratio: 1; background: #eef2f6; display: flex; align-items: center; justify-content: center; }
.card-img img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.img-placeholder { font-size: 2.5rem; opacity: .4; }
.card-body { padding: 10px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-meta { margin: 0; color: var(--muted); font-size: .8rem; }
.card-title { margin: 0; font-size: .95rem; line-height: 1.3; }
.card-title a { color: var(--text); text-decoration: none; }
.card-price { margin: 0; font-weight: 700; color: var(--navy); }
.add-form { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.add-form select { margin: 0; font-size: 16px; }
.add-row { display: flex; gap: 6px; }
.add-form .size-note { margin: 0; }
.add-row .qty { width: 58px; flex: none; padding: 8px 6px; }
.add-row button { flex: 1; padding: 0 6px; font-size: .9rem; white-space: nowrap; }
.sold-out { margin: auto 0 0; color: var(--error); font-weight: 600; font-size: .9rem; }

#load-more { display: flex; margin: 20px auto; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 20;
  max-width: 480px; margin: 0 auto;
  padding: 12px 16px; border-radius: 8px;
  background: var(--navy); color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.2);
}
.toast[hidden] { display: none; }

/* ---------- cart / checkout ---------- */

.narrow { max-width: 640px; margin: 0 auto; padding: 16px; }
.lede { margin-top: 0; }
.empty { padding: 24px 0; }

.cart-list { list-style: none; margin: 0 0 16px; padding: 0; }
.cart-line {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px;
  padding: 12px; margin-bottom: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
}
.cart-line.is-unavailable { opacity: .75; }
.cart-thumb { width: 64px; height: 64px; border-radius: 6px; background: #eef2f6; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cart-thumb img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.cart-info p { margin: 0; }
.cart-title { font-weight: 600; }
.cart-title a { color: var(--text); text-decoration: none; }
.cart-variant, .cart-unit { color: var(--muted); font-size: .9rem; }
.cart-controls { display: flex; align-items: center; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.cart-line-total { margin: 0; font-weight: 700; white-space: nowrap; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.stepper button { min-width: var(--tap); padding: 0; border-radius: 0; background: #fff; color: var(--navy); font-size: 1.2rem; }
.stepper span { min-width: 32px; text-align: center; font-weight: 600; }

.cart-footer { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.cart-footer .fine-print { margin: 0 0 8px; }
.subtotal { display: flex; justify-content: space-between; margin: 0; font-size: 1.15rem; }

.order-summary { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.order-summary summary { display: flex; justify-content: space-between; padding: 12px 14px; cursor: pointer; font-weight: 600; color: var(--navy); }
.order-summary ul { list-style: none; margin: 0; padding: 0 14px; }
.order-summary li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: .95rem; }
.order-summary li.is-unavailable { opacity: .7; text-decoration: line-through; }
.order-summary .fine-print { padding: 0 14px 12px; margin: 0; }

#checkout-form { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
#checkout-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#checkout-form button[type="submit"] { width: 100%; margin-top: 8px; font-size: 1.05rem; }
#expedited-fields { margin-top: 8px; padding: 12px; background: var(--bg); border-radius: 8px; }
.turnstile { margin: 8px 0 12px; min-height: 65px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.confirmation .order-number { font-size: 1.15rem; }
.confirmation .order-number strong { color: var(--navy); font-size: 1.35rem; }
.confirmation ol { padding-left: 20px; }
.confirmation li { margin-bottom: 6px; }

/* ---------- wider screens ---------- */

@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .search-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-areas: "search search" "audience audience" "filters results";
    column-gap: 24px;
  }
  .search-bar { grid-area: search; }
  .audience-toggle { grid-area: audience; max-width: 420px; }
  .filters { grid-area: filters; align-self: start; position: sticky; top: 80px; }
  .results { grid-area: results; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
}

@media (min-width: 1150px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
