/*
 * Shelf sandbox kit – base: reset, typography, links, focus, layout primitives.
 * Colours and fonts come only from tokens.css; this file never names a raw value of either.
 */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern", "liga";
}

main {
  flex: 1 0 auto;
}

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

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

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: var(--leading-tight);
  font-weight: 600;
  text-wrap: balance;
}
h1,
.h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.005em;
}
h2,
.h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
}
h3,
.h3 {
  font-size: var(--text-md);
  font-weight: 600;
}
@media (min-width: 960px) {
  h1,
  .h1 {
    font-size: var(--text-3xl);
  }
}

p {
  margin: 0;
}
p + p {
  margin-top: var(--space-3);
}

.prose {
  max-width: var(--measure);
}
.prose > * + * {
  margin-top: var(--space-3);
}
.prose h2 {
  margin-top: var(--space-6);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover {
  color: var(--accent-hover);
}

code,
kbd,
samp,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
code {
  padding: 0.08em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--sunken);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: var(--space-6) 0;
}

::selection {
  background: var(--accent);
  color: var(--on-accent);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* Browser autofill must not paint its own yellow/blue over the theme. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--raised) inset;
  caret-color: var(--ink);
}

* {
  scrollbar-color: var(--line-strong) transparent;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ── Small helpers ─────────────────────────────────────────── */

/* `hidden` always wins over a component's display. */
[hidden] {
  display: none !important;
}


.label {
  font-family: var(--font-label);
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--label);
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--ink-2);
}
.faint {
  color: var(--ink-3);
}
.small {
  font-size: var(--text-sm);
}
.tiny {
  font-size: var(--text-xs);
}
.num,
.price {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.clamp-1,
.clamp-2,
.clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clamp-1 { -webkit-line-clamp: 1; line-clamp: 1; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }

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

/* Hide by width without `hidden` (extensions ship `.hidden{display:none!important}`). */
@media (max-width: 959px) {
  .only-wide { display: none !important; }
}
@media (min-width: 960px) {
  .only-narrow { display: none !important; }
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--raised);
  color: var(--ink);
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
}
.skip-link:focus {
  top: var(--space-2);
}

/* ── Layout primitives ─────────────────────────────────────── */

/* The page spans the window; contents are inset by the gutter, never locked in a narrow column. */
.page {
  width: 100%;
  padding: var(--space-6) var(--gutter) var(--space-12);
}

.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-8); }

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

/* Sticky rail on the left, work area on the right; the rail drops above the work on phones. */
.layout-rail {
  display: grid;
  gap: var(--space-6);
}
@media (min-width: 960px) {
  .layout-rail {
    grid-template-columns: 15.5rem minmax(0, 1fr);
    align-items: start;
  }
  .layout-rail > .rail {
    position: sticky;
    top: calc(var(--header-h) + var(--space-4));
  }
}

/* Work on the left, a summary on the right (cart, checkout, order). */
.layout-split {
  display: grid;
  gap: var(--space-6);
}
@media (min-width: 960px) {
  .layout-split {
    grid-template-columns: minmax(0, 1fr) 22rem;
    align-items: start;
  }
  .layout-split > .aside {
    position: sticky;
    top: calc(var(--header-h) + var(--space-4));
  }
}
@media (min-width: 1440px) {
  .layout-split {
    grid-template-columns: minmax(0, 1fr) 26rem;
  }
}

/* Two equal halves (product page, account). */
.layout-halves {
  display: grid;
  gap: var(--space-6);
}
@media (min-width: 960px) {
  .layout-halves {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

/* A grid of cards that fills the width: 1 column on a phone, as many as fit elsewhere. */
.grid-cards {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 14.5rem), 1fr));
}
@media (max-width: 559px) {
  .grid-cards--two-on-phone {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }
}

/* A single centred form – allowed for sign-in and sign-up only. */
.layout-form {
  display: grid;
  place-items: start center;
  padding-top: clamp(var(--space-6), 8vh, var(--space-12));
}
.layout-form > * {
  width: min(100%, 26rem);
}
