/* ==========================================================================
   Twig Tree — vintage streetwear resale
   Palette: warm paper, ink, olive accents. Serif display, quiet sans body.
   ========================================================================== */

:root {
  --paper: #f4f1ea;        /* page background */
  --paper-raised: #fbf9f4; /* cards / panels */
  --paper-deep: #ebe6d9;   /* the sourcing band — a shade warmer than the page */
  --ink: #1c1a17;          /* primary text */
  --ink-soft: #5d574d;     /* secondary text */
  --line: #d9d3c6;         /* hairlines */
  --olive: #4a5138;        /* accent */
  --olive-dark: #363c28;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --gap: 18px;             /* grid gutter — JS reads column count from the grid */
  --ease: cubic-bezier(0.22, 1, 0.36, 1); /* soft decel for expand/collapse */
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  position: relative;   /* anchors the .side-design artwork */
  overflow-x: clip;     /* its right edge sits 1px past the viewport */
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---- Side branch artwork (index page): right edge flush with (1px past)
       the viewport edge, starting a third of the way into the hero, running
       down behind the listings. Behind everything, clicks pass through. ---- */
.side-design {
  position: absolute;
  top: 33vh;
  top: 33svh;
  right: -1px;
  width: min(27vw, 400px);
  z-index: -1;              /* behind hero + tiles, above the paper */
  pointer-events: none;
  mix-blend-mode: multiply; /* ink on paper even if the PNG loses its alpha */
}

a { color: inherit; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ==========================================================================
   HERO — animated intro (logic in js/hero.js)
   Warm paper, ink mark. The logo flashes centered and oversized, settles
   into its big resting spot, then a typewriter cycles words beneath it.
   ========================================================================== */

.hero {
  /* Layout knobs: */
  --logo-top: 92px;                  /* resting position below the nav */
  --logo-h: min(56vh, 600px);        /* resting logo height — most of the hero */
  --logo-h-intro: min(66vh, 700px);  /* oversized intro logo height */
  --type-gap: 42px;                  /* air between logo base and the typed word */

  position: relative;
  height: 100vh;
  height: 100svh;
  color: var(--ink);
  overflow: hidden;
}

/* accessible page title (visual heading duty is done by the logo) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.hero__nav {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 28px;
}

.hero__nav-brand {
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: 0.04em;
  text-decoration: none;
}

.hero__nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}

.hero__nav-links a {
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.9;
}
.hero__nav-links a:hover { opacity: 1; text-decoration: underline; }

.cart-toggle {
  background: none;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cart-toggle:hover { background: rgba(28, 26, 23, 0.07); }

.cart-toggle__count {
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  min-width: 19px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 0 5px;
}
.cart-toggle__count[hidden] { display: none; }

/* ---- Logo: two states, INTRO (oversized, dead-center) and SETTLED
        (big, top-center). js/hero.js flips the classes; the move
        between them is a plain CSS transition. ---- */

.hero__logo {
  position: absolute;
  z-index: 1;
  left: 50%;
  /* default = settled, so the layout is sane even without JS */
  top: var(--logo-top);
  height: var(--logo-h);
  width: auto;
  transform: translateX(-50%);
  transition:
    top    0.9s var(--ease),
    height 0.9s var(--ease),
    transform 0.9s var(--ease);
}

.hero__logo.is-intro {
  top: 46%;
  height: var(--logo-h-intro);
  transform: translate(-50%, -50%);
  opacity: 0; /* until the flash plays */
}

/* The flash: a quick opacity/glow pulse with a slight scale overshoot.
   Runs once at the intro position, then hero.js swaps to .is-settled. */
.hero__logo.is-flashing {
  animation: logo-flash 0.5s ease-out forwards;
}

@keyframes logo-flash {
  0%   { opacity: 0;    transform: translate(-50%, -50%) scale(0.92); filter: drop-shadow(0 0 0 rgba(74, 81, 56, 0)); }
  30%  { opacity: 1;    transform: translate(-50%, -50%) scale(1.06); filter: drop-shadow(0 0 26px rgba(74, 81, 56, 0.75)); }
  55%  { opacity: 0.55; transform: translate(-50%, -50%) scale(1.02); filter: drop-shadow(0 0 8px rgba(74, 81, 56, 0.3)); }
  100% { opacity: 1;    transform: translate(-50%, -50%) scale(1);    filter: drop-shadow(0 0 0 rgba(74, 81, 56, 0)); }
}

/* ---- Typewriter masthead ---- */

.hero__type {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  top: calc(var(--logo-top) + var(--logo-h) + var(--type-gap));
  text-align: center;
  font-family: var(--serif);
  font-size: clamp(34px, 6vw, 58px);
  line-height: 1;
  letter-spacing: 0.09em;
  color: var(--ink);
}

/* pre lives on the word span only: a mid-type trailing space ("one ") must
   keep its width, but the container must not render markup whitespace */
.hero__word { white-space: pre; }

.hero__cursor {
  display: inline-block;
  width: 3px;
  height: 1.05em;
  margin-left: 5px;
  background: var(--ink);
  vertical-align: -0.12em;
  visibility: hidden; /* hero.js reveals it when typing starts */
}
.hero__cursor.is-on { visibility: visible; }
.hero__cursor.is-blinking { animation: cursor-blink 1.05s steps(1) infinite; }

@keyframes cursor-blink {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: 0; }
}

.hero__scroll-cue {
  position: absolute;
  z-index: 1;
  left: 50%;
  transform: translateX(-50%);
  bottom: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.7;
}
.hero__scroll-cue:hover { opacity: 1; }
.hero__scroll-cue svg { animation: cue-bob 2.2s var(--ease) infinite; }

@keyframes cue-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(6px); }
}

/* ==========================================================================
   SUBHEAD (Sold page header)
   ========================================================================== */

.subhead { border-bottom: 1px solid var(--line); }
.subhead__nav { color: var(--ink); }
.subhead__body { text-align: center; padding: 48px 24px 56px; }
.subhead__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 6vw, 64px);
  margin: 0;
}
.subhead__sub { color: var(--ink-soft); margin-top: 10px; }

/* ==========================================================================
   SHOP GRID
   3 columns desktop → 1 column phones. The detail row spans all columns.
   ========================================================================== */

.shop {
  max-width: 1160px;
  margin: 0 auto;
  padding: 56px 24px 90px;
}

.shop__intro {
  color: var(--ink-soft);
  font-size: 14px;
  letter-spacing: 0.02em;
  margin: 0 0 32px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* JS reads this to find each tile's row */
  gap: 28px var(--gap);
  align-items: start;
}

/* ---- Tile ---- */

.tile {
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  display: block;
  width: 100%;
}

.tile__img-wrap {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  aspect-ratio: 4 / 5;
  overflow: hidden;
}

.tile__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s var(--ease);
}
.tile:hover .tile__img { transform: scale(1.03); }

.tile__meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 10px;
}

.tile__name {
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.3;
}

.tile__price {
  font-size: 14px;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* The tile currently expanded lives on inside the detail row; its grid slot
   is removed so former row-mates flow down into the next row. */
.tile--expanded { display: none; }

/* Invisible cell in row 1, column 3 of the shop grid (inserted by main.js):
   keeps the first row at two items so the side artwork has breathing room.
   While a detail row is open the grid reverts to full three-across flow. */
.grid:has(.detail) .grid__spacer { display: none; }

/* Sold page variant */
.grid--sold .tile { cursor: default; }
.tile__sold-flag {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  padding: 3px 9px;
}
.grid--sold .tile__img { filter: saturate(0.6); opacity: 0.85; }

/* ==========================================================================
   DETAIL ROW — the in-place expansion (see js/main.js)

   Spans all 3 grid columns. Internally: the featured image column is 1.5×
   a normal tile width (the "~150% scale"), and the info panel takes the
   rest — visually the space where columns 2–3 sit.
   ========================================================================== */

.detail {
  grid-column: 1 / -1;           /* full-width row inside the main grid */
  overflow: hidden;              /* lets us animate height on expand/collapse */
  background: var(--paper-raised);
  border: 1px solid var(--line);
}

.detail__inner {
  position: relative;
  display: grid;
  /* 1.5 tile-widths for the image, remaining ~1.5 for the panel.
     Total grid width = 3 tiles + 2 gaps, so:  */
  grid-template-columns: calc(50% - var(--gap) / 2) 1fr;
  gap: 0 calc(var(--gap) * 1.5);
  padding: 26px;
}

/* ---- Featured image + gallery ---- */

.detail__media { min-width: 0; }

.detail__cover-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  aspect-ratio: 4 / 5;           /* same ratio as tiles, 1.5× the width */
  overflow: hidden;
}

.detail__cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Quick crossfade when a thumbnail swaps into the cover slot */
.detail__cover.is-swapping { animation: cover-fade 0.35s var(--ease); }
@keyframes cover-fade { from { opacity: 0.25; } to { opacity: 1; } }

.detail__thumbs {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.detail__thumb {
  padding: 0;
  border: 1px solid var(--line);
  background: var(--paper);
  width: 64px;
  height: 80px;
  overflow: hidden;
  opacity: 0.75;
}
.detail__thumb img { width: 100%; height: 100%; object-fit: cover; }
.detail__thumb:hover { opacity: 1; }
.detail__thumb.is-active {
  opacity: 1;
  border-color: var(--ink);
}

/* ---- Info panel ---- */

.detail__info {
  min-width: 0;
  padding: 6px 44px 0 0;         /* right padding keeps text clear of the close button */
  display: flex;
  flex-direction: column;
}

.detail__name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
  margin: 0 0 6px;
}

.detail__price {
  font-size: 18px;
  color: var(--olive);
  margin: 0 0 18px;
}

.detail__specs {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 18px;
  margin: 0 0 18px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.detail__specs dt {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  align-self: baseline;
}
.detail__specs dd { margin: 0; align-self: baseline; }

.detail__story {
  color: var(--ink-soft);
  margin: 0 0 24px;
  max-width: 56ch;
}

.detail__actions { margin-top: auto; padding-bottom: 4px; }

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

.btn {
  border: 1px solid var(--ink);
  background: none;
  padding: 12px 28px;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background 0.2s, color 0.2s;
}

.btn--primary {
  background: var(--olive);
  border-color: var(--olive);
  color: var(--paper);
}
.btn--primary:hover { background: var(--olive-dark); border-color: var(--olive-dark); }

.btn[disabled] { opacity: 0.55; cursor: default; }

/* ---- Circular close button, top-right of the detail row ---- */

.icon-btn {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
}
.icon-btn:hover { background: var(--ink); color: var(--paper); transform: rotate(90deg); }

.detail__close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
}

/* ==========================================================================
   CART — slide-out panel, bottom-right
   ========================================================================== */

.cart {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 92vw);
  background: var(--paper-raised);
  border-left: 1px solid var(--line);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s var(--ease);
}
.cart.is-open { transform: translateX(0); }

.cart-scrim {
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 23, 0.35);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.35s;
}
.cart-scrim.is-open { opacity: 1; }

.cart__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.cart__head h2 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0; }

.cart__list {
  list-style: none;
  margin: 0;
  padding: 8px 22px;
  overflow-y: auto;
  flex: 1;
}

.cart__item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.cart__item img { width: 52px; height: 65px; object-fit: cover; border: 1px solid var(--line); }
.cart__item-name { font-family: var(--serif); font-size: 15px; }
.cart__item-price { color: var(--ink-soft); font-size: 13px; }
.cart__item-body { flex: 1; min-width: 0; }

.cart__remove {
  background: none;
  border: 0;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: underline;
  padding: 4px;
}
.cart__remove:hover { color: var(--ink); }

.cart__empty { padding: 26px 22px; color: var(--ink-soft); }

.cart__foot { padding: 18px 22px 24px; border-top: 1px solid var(--line); }
.cart__total {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  margin: 0 0 14px;
}
.cart__foot .btn { width: 100%; }
.cart__note { font-size: 12px; color: var(--ink-soft); margin: 10px 0 0; }

/* Floating cart button once you've scrolled past the hero nav */
.cart-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  background: var(--ink);
  color: var(--paper);
  border: 0;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(28, 26, 23, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}
.cart-fab.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.cart-fab .cart-toggle__count { background: var(--paper); color: var(--ink); }

/* ==========================================================================
   SOURCING — "hire me to find it" band (form logic in js/sourcing.js)
   Sits after the grid on a deeper paper shade so it reads as its own band.
   ========================================================================== */

.sourcing {
  background: var(--paper-deep);
  border-top: 1px solid var(--line);
}

.sourcing__inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 72px 24px 84px;
  display: grid;
  grid-template-columns: 5fr 6fr;   /* editorial copy left, form right */
  gap: 48px clamp(40px, 6vw, 96px);
  align-items: start;
}

.sourcing__eyebrow {
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--olive);
  margin: 0 0 14px;
}

.sourcing__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 3.6vw, 44px);
  line-height: 1.12;
  margin: 0 0 18px;
}

.sourcing__pitch {
  color: var(--ink-soft);
  max-width: 46ch;
  margin: 0 0 28px;
}

/* the 3-step: quiet list, serif numerals in olive */
.sourcing__steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.sourcing__steps li {
  counter-increment: step;
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.sourcing__steps li::before {
  content: counter(step) ".";
  font-family: var(--serif);
  font-size: 19px;
  color: var(--olive);
}

/* ---- The request form ---- */

.sourcing__form { display: flex; flex-direction: column; gap: 18px; }
/* display:flex would beat the [hidden] attribute after submit — force it */
.sourcing__form[hidden] { display: none; }

.sourcing__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.sourcing__field { display: flex; flex-direction: column; gap: 6px; }

.sourcing__field label {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.sourcing__field label span { text-transform: none; letter-spacing: 0.02em; }

.sourcing__field input,
.sourcing__field textarea {
  font: inherit;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 13px;
}
.sourcing__field textarea { resize: vertical; min-height: 110px; }

.sourcing__field input:focus,
.sourcing__field textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.sourcing__field ::placeholder { color: var(--ink-soft); opacity: 0.6; }

.sourcing__submit { align-self: flex-start; margin-top: 4px; }

.sourcing__error { color: #8a3b2e; font-size: 14px; margin: 0; }

/* honeypot — visually gone, still in the DOM for bots to trip on */
.sourcing__trap {
  position: absolute;
  left: -9999px;
  margin: 0;
}

/* ---- Thank-you state (js/sourcing.js swaps it in for the form) ---- */

.sourcing__thanks { padding: 24px 0; outline: none; }
.sourcing__thanks-title {
  font-family: var(--serif);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.2;
  margin: 0 0 10px;
}
.sourcing__thanks-sub { color: var(--ink-soft); margin: 0; }

/* ==========================================================================
   FOOTER
   ========================================================================== */

.footer {
  border-top: 1px solid var(--line);
  padding: 30px 24px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
}

/* ==========================================================================
   RESPONSIVE
   3 cols → 2 cols (tablet) → 1 col (phone). On phones the detail panel
   stacks BELOW the featured image.
   ========================================================================== */

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }

  /* no room for the side artwork or the row-1 gap on narrow layouts */
  .side-design { display: none; }
  .grid__spacer { display: none; }

  /* sourcing: copy stacks above the form */
  .sourcing__inner { grid-template-columns: 1fr; gap: 40px; padding: 56px 24px 64px; }
}

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }

  .detail__inner {
    grid-template-columns: 1fr;   /* image on top, info below */
    gap: 22px;
    padding: 18px;
  }

  .detail__info { padding-right: 0; }
  .detail__close { top: 12px; right: 12px; }
  /* keep the close button clear of the name on small screens */
  .detail__name { padding-right: 40px; }

  /* three nav links + cart have to share a phone width */
  .hero__nav { padding: 18px 16px; gap: 10px; }
  .hero__nav-brand { font-size: 18px; }
  .hero__nav-links { gap: 12px; }
  .hero__nav-links a {
    font-size: 10.5px;
    letter-spacing: 0.06em;
    white-space: nowrap;
  }
  .cart-toggle { padding: 5px 11px; font-size: 10.5px; letter-spacing: 0.06em; }

  .shop { padding-top: 40px; }

  /* sourcing form fields stack in one column */
  .sourcing__row { grid-template-columns: 1fr; }
  .sourcing__submit { align-self: stretch; }

  /* slightly smaller logo so the word stays comfortably on screen */
  .hero {
    --logo-top: 80px;
    --logo-h: min(50vh, 440px);
    --logo-h-intro: min(58vh, 500px);
    --type-gap: 32px;
  }
}

/* Respect reduced-motion users: skip the expand/collapse animation,
   the logo intro, and the cursor blink (hero.js also skips its sequence) */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .detail, .tile__img, .cart, .cart-scrim,
  .hero__logo, .hero__cursor { transition: none !important; animation: none !important; }
  .hero__scroll-cue svg { animation: none; }
}
