/* Garden Cosy — shared design system: tokens, type, buttons, forms, switches, notices.
   Used by the storefront, the sign-in page and both panels. */

@font-face {
  font-family: 'Fraunces';
  src: url('../fonts/fraunces-latin-full-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('../fonts/fraunces-latin-full-italic.woff2') format('woff2');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Figtree';
  src: url('../fonts/figtree-latin-wght-normal.woff2') format('woff2');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Colour: warm linen, deep garden greens, a terracotta accent. */
  --paper: #f5f1e8;
  --paper-deep: #ebe5d6;
  --surface: #fffdf8;
  --ink: #1c2620;
  --ink-soft: #46524b;
  --ink-mute: #6f7a73;
  --moss: #2f4a3a;
  --moss-deep: #1f3327;
  --moss-bright: #3d6149;
  --sage: #b9c4ae;
  --sage-soft: #e1e7d8;
  --clay: #a64f2c;
  --clay-soft: #f4e0d4;
  --gold: #b98a3a;
  --line: rgba(28, 38, 32, 0.12);
  --line-strong: rgba(28, 38, 32, 0.24);
  --success: #2c6a45;
  --success-soft: #dcebdf;
  --warning: #8a5d0c;
  --warning-soft: #f6e8c8;
  --danger: #a3352a;
  --danger-soft: #f6dcd7;
  --info: #2c5568;
  --info-soft: #dbe8ee;
  --focus: #1d6fb8;

  /* Type */
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text-xs: 0.78rem;
  --text-s: 0.875rem;
  --text-m: 1rem;
  --text-l: 1.125rem;
  --text-xl: clamp(1.3rem, 1.1rem + 0.8vw, 1.6rem);
  --text-2xl: clamp(1.7rem, 1.3rem + 1.6vw, 2.4rem);
  --text-3xl: clamp(2.2rem, 1.5rem + 3vw, 3.6rem);
  --text-hero: clamp(2.7rem, 1.4rem + 5.4vw, 5.4rem);

  /* Space and shape */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-9: 7rem;
  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 24px;
  --radius-xl: 36px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(28, 38, 32, 0.05), 0 6px 20px rgba(28, 38, 32, 0.06);
  --shadow-2: 0 18px 50px rgba(28, 38, 32, 0.16);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --speed: 220ms;
  --page: min(1280px, 100% - 2 * var(--gutter));
  --gutter: clamp(1.1rem, 4vw, 3rem);
  --control: 2.9rem; /* minimum touch-sized control height */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-m);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 420;
  line-height: 1.08;
  letter-spacing: -0.015em;
  font-variation-settings: 'SOFT' 60, 'WONK' 0;
  text-wrap: balance;
}

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: var(--moss);
  color: var(--paper);
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -4rem;
  z-index: 200;
  padding: 0.7rem 1.1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-s);
  transition: top var(--speed) var(--ease);
}
.skip-link:focus {
  top: var(--space-4);
}

.icon {
  flex: none;
}

.eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--moss-bright);
}

.muted {
  color: var(--ink-mute);
}

/* ---------- Buttons ---------- */

.btn {
  --btn-bg: var(--moss);
  --btn-fg: var(--paper);
  --btn-border: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: var(--control);
  padding: 0.6rem 1.35rem;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  font-size: var(--text-m);
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease), border-color var(--speed) var(--ease),
    transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.btn:hover {
  --btn-bg: var(--moss-deep);
}
.btn:active {
  transform: translateY(1px) scale(0.99);
}
.btn--secondary {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  --btn-border: var(--line-strong);
}
.btn--secondary:hover {
  --btn-bg: rgba(28, 38, 32, 0.06);
  --btn-border: var(--ink);
}
.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
}
.btn--ghost:hover {
  --btn-bg: rgba(28, 38, 32, 0.07);
}
.btn--light {
  --btn-bg: var(--paper);
  --btn-fg: var(--ink);
}
.btn--light:hover {
  --btn-bg: #fff;
}
.btn--danger {
  --btn-bg: transparent;
  --btn-fg: var(--danger);
  --btn-border: rgba(163, 53, 42, 0.4);
}
.btn--danger:hover {
  --btn-bg: var(--danger-soft);
}
.btn--small {
  min-height: 2.3rem;
  padding: 0.35rem 0.95rem;
  font-size: var(--text-s);
}
.btn--large {
  min-height: 3.4rem;
  padding: 0.8rem 1.9rem;
  font-size: var(--text-l);
}
.btn--block {
  width: 100%;
}
.btn--icon {
  width: var(--control);
  padding: 0;
}
.btn--icon.btn--small {
  width: 2.3rem;
}
.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Pending state shared by buttons that trigger asynchronous work. */
.btn.is-loading {
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading > * {
  visibility: hidden;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 2px solid var(--btn-fg);
  border-right-color: transparent;
  animation: gc-spin 0.7s linear infinite;
}
@keyframes gc-spin {
  to {
    transform: rotate(360deg);
  }
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
}
.link-arrow .icon {
  transition: transform var(--speed) var(--ease);
}
.link-arrow:hover .icon {
  transform: translateX(4px);
}

/* ---------- Forms ---------- */

.field {
  display: grid;
  gap: 0.4rem;
}
.field + .field {
  margin-top: var(--space-4);
}
.field__label {
  font-weight: 600;
  font-size: var(--text-s);
}
.field__hint {
  font-size: var(--text-s);
  color: var(--ink-mute);
}
.field__error {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  font-size: var(--text-s);
  font-weight: 500;
  color: var(--danger);
}
.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--control);
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}
.textarea {
  min-height: 8rem;
  line-height: 1.55;
  resize: vertical;
}
.select {
  appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231c2620' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
}
.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--ink-mute);
}
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--moss);
  box-shadow: 0 0 0 3px rgba(47, 74, 58, 0.22);
}
.input[aria-invalid='true'],
.select[aria-invalid='true'],
.textarea[aria-invalid='true'] {
  border-color: var(--danger);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--ink-mute);
  opacity: 0.8;
}
.input-group {
  display: flex;
  align-items: stretch;
}
.input-group__addon {
  display: grid;
  place-items: center;
  padding: 0 0.85rem;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-radius: var(--radius-s) 0 0 var(--radius-s);
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-weight: 600;
}
.input-group .input {
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
}

.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
  line-height: 1.4;
}
.check input {
  width: 1.2rem;
  height: 1.2rem;
  margin: 0.1rem 0 0;
  accent-color: var(--moss);
  flex: none;
}

/* ---------- Switch ---------- */
/* A <button role="switch"> whose look always follows aria-checked, i.e. the confirmed state. */

.switch {
  --switch-w: 3rem;
  --switch-h: 1.75rem;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--control);
  padding: 0;
  border: 0;
  background: none;
  font-size: var(--text-s);
  font-weight: 600;
  text-align: left;
}
.switch__track {
  position: relative;
  flex: none;
  width: var(--switch-w);
  height: var(--switch-h);
  border-radius: var(--radius-pill);
  background: #c9cdc4;
  box-shadow: inset 0 0 0 1px rgba(28, 38, 32, 0.12);
  transition: background var(--speed) var(--ease);
}
.switch__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(var(--switch-h) - 6px);
  height: calc(var(--switch-h) - 6px);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(28, 38, 32, 0.35);
  transition: transform var(--speed) var(--ease);
}
.switch[aria-checked='true'] .switch__track {
  background: var(--success);
}
.switch[aria-checked='true'] .switch__thumb {
  transform: translateX(calc(var(--switch-w) - var(--switch-h)));
}
.switch__label {
  min-width: 4.2em;
  color: var(--ink-soft);
}
.switch[aria-checked='true'] .switch__label {
  color: var(--success);
}
.switch[aria-busy='true'] {
  cursor: progress;
}
.switch[aria-busy='true'] .switch__thumb::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 2px solid var(--moss);
  border-right-color: transparent;
  animation: gc-spin 0.7s linear infinite;
}
.switch[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
}
.switch.has-failed .switch__track {
  box-shadow: 0 0 0 2px var(--danger);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.5;
  white-space: nowrap;
}
.badge--success {
  background: var(--success-soft);
  color: var(--success);
}
.badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge--info {
  background: var(--info-soft);
  color: var(--info);
}
.badge--clay {
  background: var(--clay-soft);
  color: var(--clay);
}
.badge--solid {
  background: var(--ink);
  color: var(--paper);
}

/* ---------- Notices (inline) ---------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--text-s);
  line-height: 1.5;
}
.notice .icon {
  margin-top: 0.1rem;
}
.notice strong {
  font-weight: 650;
}
.notice--success {
  background: var(--success-soft);
  border-color: transparent;
  color: #1d4a30;
}
.notice--warning {
  background: var(--warning-soft);
  border-color: transparent;
  color: #5f4008;
}
.notice--error {
  background: var(--danger-soft);
  border-color: transparent;
  color: #7a251c;
}
.notice--info {
  background: var(--info-soft);
  border-color: transparent;
  color: #1f4252;
}
.notice-stack {
  display: grid;
  gap: var(--space-3);
}

/* ---------- Toasts (asynchronous feedback) ---------- */

.toast-region {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 300;
  display: grid;
  gap: 0.6rem;
  width: min(24rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 0.9rem 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-2);
  font-size: var(--text-s);
  line-height: 1.45;
  pointer-events: auto;
  animation: gc-toast-in 320ms var(--ease) both;
}
.toast.is-leaving {
  animation: gc-toast-out 200ms ease-in both;
}
.toast__body {
  flex: 1;
}
.toast__body a {
  font-weight: 650;
}
.toast--success .icon:first-child {
  color: #9fd5b2;
}
.toast--error {
  background: #6f2219;
}
.toast--warning .icon:first-child {
  color: #f0cf85;
}
.toast__close {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  margin: -0.2rem -0.2rem 0 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: 0.75;
}
.toast__close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.14);
}
@keyframes gc-toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}
@keyframes gc-toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Media fallback ---------- */
/* A deliberate placeholder for products without a usable photograph. */

.media-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 6rem;
  background: radial-gradient(120% 90% at 20% 10%, #eef1e6 0%, transparent 60%), linear-gradient(145deg, var(--sage-soft), var(--paper-deep));
  color: var(--moss-bright);
  text-align: center;
}
.media-fallback__inner {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  padding: 1rem;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* Applied by core.js to the frame of a photograph that failed to load. */
.media-missing {
  background: radial-gradient(120% 90% at 20% 10%, #eef1e6 0%, transparent 60%), linear-gradient(145deg, var(--sage-soft), var(--paper-deep)) !important;
}

/* ---------- Empty state ---------- */

.empty-state {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--ink-soft);
}
.empty-state__icon {
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: var(--sage-soft);
  color: var(--moss);
}
.empty-state h2,
.empty-state h3 {
  font-size: var(--text-xl);
  color: var(--ink);
}
.empty-state p {
  max-width: 34rem;
}

/* ---------- Quantity stepper ---------- */

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
}
.stepper__btn {
  display: grid;
  place-items: center;
  width: var(--control);
  height: var(--control);
  border: 0;
  border-radius: 50%;
  background: transparent;
  transition: background var(--speed) var(--ease);
}
.stepper__btn:hover:not([disabled]) {
  background: rgba(28, 38, 32, 0.07);
}
.stepper__btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}
.stepper__input {
  width: 3.2rem;
  height: var(--control);
  border: 0;
  background: transparent;
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper__input::-webkit-outer-spin-button,
.stepper__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.stepper__input:focus-visible {
  outline-offset: -2px;
}

/* ---------- Motion helpers ---------- */
/* Content is visible by default; JavaScript opts elements in to a reveal only when motion is welcome. */

.js-motion [data-reveal] {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .js-motion [data-reveal] {
    opacity: 1;
  }
}

/* If the scripts fail to load, reveal-on-scroll content must still appear. */
.js-motion:not(.gc-ready) [data-reveal] {
  animation: gc-reveal-failsafe 1ms 3s forwards;
}
@keyframes gc-reveal-failsafe {
  to {
    opacity: 1;
  }
}
