/* The tab bar of a homeware shop app, alone on white. The bar and the bag sheet are one surface: the script only
   changes its height (and moves the pill, the icons, the rows and the pointer); colours, edges and states live in
   CSS on classes. A GSAP element never has a transform in the CSS. */
:root {
  --page: #ffffff;          /* the page */
  --surface: #fbfaf7;       /* the bar and the sheet */
  --edge: rgba(26, 24, 19, 0.08);  /* the 1px edge */
  --ink: #1a1813;           /* the main text, the checkout button */
  --muted: #8b867b;         /* labels, variants, idle icons */
  --pill: #efece5;          /* the pill under the chosen tab */
  --accent: #c4532f;        /* the one accent: the badge, the shipping line */
  --linen: #d9cdb6;         /* the linen tile */
  --glaze: #8fb0ad;         /* the stoneware tile */
  --wax: #e2b660;           /* the beeswax tile */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { appearance: none; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 12px;
}

/* the dock is as tall as the open sheet, so the closed bar sits where the open sheet ends */
.dock {
  position: relative;
  width: min(360px, calc(100vw - 28px));
  height: var(--open, 360px);
}

/* ---- the one surface ---- */
.shop {
  --lift: 0;
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 68px;
  border-radius: 26px;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface) 60%);
  border: 1px solid var(--edge);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 2px rgba(26, 24, 19, 0.05),
    0 calc(6px + var(--lift) * 16px) calc(16px + var(--lift) * 34px) calc(-6px - var(--lift) * 8px) rgba(26, 24, 19, calc(0.12 + var(--lift) * 0.08)),
    0 calc(18px + var(--lift) * 30px) calc(40px + var(--lift) * 50px) calc(-20px - var(--lift) * 10px) rgba(80, 52, 30, calc(0.10 + var(--lift) * 0.1));
}
.shop__sheen {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(90% 40% at 50% 0%, rgba(196, 83, 47, 0.06), transparent 70%);
  opacity: var(--lift);
}

/* ---- the sheet (above the bar, revealed as the surface grows) ---- */
.sheet {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 67px;
  overflow: hidden;
  border-radius: 25px 25px 0 0;
}
.sheet__inner {
  position: absolute; left: 0; right: 0; top: 0;
  padding: 0 clamp(12px, 4vw, 16px) clamp(8px, 1.8vh, 12px);
  display: grid;
  gap: clamp(6px, 1.6vh, 10px);
}
.sheet__grab { display: grid; place-items: center; height: clamp(14px, 3vh, 18px); cursor: grab; touch-action: none; }
.sheet__grab span { width: 34px; height: 4px; border-radius: 4px; background: rgba(26, 24, 19, 0.14); }

.bag-head { display: flex; align-items: center; gap: 10px; touch-action: none; cursor: grab; }
.bag-head__txt { display: grid; line-height: 1.15; min-width: 0; }
.bag-head__title { font-size: clamp(16px, 2.7vh, 18px); font-weight: 660; letter-spacing: -0.02em; }
.bag-head__sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.shut {
  margin-left: auto; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: #f1eee8;
  box-shadow: inset 0 0 0 1px rgba(26, 24, 19, 0.05);
  transition: background 0.25s ease;
}
.shut svg { width: 14px; height: 14px; fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linecap: round; }
.shut:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (hover: hover) { .shut:hover { background: #e8e4dc; } }

/* ---- the items ---- */
.items { list-style: none; display: grid; gap: clamp(2px, 0.8vh, 6px); }
.item {
  display: flex; align-items: center; gap: 11px;
  height: clamp(42px, 9.4vh, 54px);
  padding: 0 4px;
  border-radius: 14px;
}
.tile {
  flex: none;
  width: clamp(34px, 7.4vh, 42px); height: clamp(34px, 7.4vh, 42px);
  border-radius: 11px;
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -1px 0 rgba(0, 0, 0, 0.08), 0 2px 5px -2px rgba(40, 30, 20, 0.25);
}
.tile svg { width: 64%; height: 64%; fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.tile--linen {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg, rgba(90, 70, 40, 0.07) 0 1px, transparent 1px 3px),
    linear-gradient(160deg, #e7dcc7, var(--linen) 60%, #c9bb9f);
}
.tile--linen svg { stroke: #8a7651; }
.tile--glaze {
  background:
    radial-gradient(60% 50% at 30% 22%, rgba(255, 255, 255, 0.55), transparent 60%),
    linear-gradient(170deg, #a9c6c2, var(--glaze) 55%, #6f918e);
}
.tile--glaze svg { stroke: #f4f8f6; }
.tile--wax {
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 2px, transparent 2px 5px),
    linear-gradient(165deg, #f0cd80, var(--wax) 55%, #c9953f);
}
.tile--wax svg { stroke: #8a5f1c; }
.item__txt { display: grid; line-height: 1.2; min-width: 0; flex: 1; }
.item__name { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__var { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.item__price { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }

/* ---- free shipping ---- */
.ship { display: grid; gap: 6px; padding: 0 4px; }
.ship__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ship__label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 560; }
.ship__label svg { width: 15px; height: 15px; fill: none; stroke: var(--accent); stroke-width: 1.3; stroke-linejoin: round; }
.ship__note { font-size: 11.5px; color: var(--muted); }
.ship__track { position: relative; height: 3px; border-radius: 3px; background: rgba(26, 24, 19, 0.07); overflow: hidden; }
.ship__fill { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, #e0805e, var(--accent)); transform-origin: 0 50%; }

/* ---- the checkout button ---- */
.pay {
  position: relative;
  height: clamp(42px, 8.4vh, 50px);
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(180deg, #2a2720, var(--ink));
  color: #f6f3ec;
  box-shadow: 0 10px 20px -12px rgba(26, 24, 19, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 -1px 0 rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.3s ease;
}
.pay:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.pay__face { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.pay__label { font-size: 14.5px; font-weight: 640; font-variation-settings: "wdth" 100; transition: font-variation-settings 0.35s ease; }
.pay__total { font-size: 14px; font-weight: 560; color: rgba(246, 243, 236, 0.7); }
.pay__done { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14.5px; font-weight: 640; opacity: 0; }
.pay__done svg { width: 18px; height: 18px; fill: none; stroke: #f6f3ec; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pay__sweep {
  position: absolute; top: 0; bottom: 0; left: 0; width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.16), transparent);
  opacity: 0; pointer-events: none;
}
@media (hover: hover) {
  .pay:hover { box-shadow: 0 14px 26px -12px rgba(26, 24, 19, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.18), inset 0 -1px 0 rgba(0, 0, 0, 0.3); }
  .pay:hover .pay__label { font-variation-settings: "wdth" 114; }
}

/* ---- the tab bar ---- */
.tabs {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 68px;
  display: flex;
  padding: 0 6px;
}
.tabs::before {
  content: ""; position: absolute; left: 18px; right: 18px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(26, 24, 19, 0.08), transparent);
  opacity: var(--lift);
}
.tabs__pill, .tabs__hover {
  position: absolute; left: 0; top: 8px;
  height: 52px; width: 60px;
  pointer-events: none;
}
.tabs__pillface {
  position: absolute; inset: 0; border-radius: 18px;
  background: linear-gradient(180deg, #f3f0ea, var(--pill));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 0 0 1px rgba(26, 24, 19, 0.04), 0 1px 2px rgba(26, 24, 19, 0.06);
}
.tabs__hover { border-radius: 18px; background: rgba(26, 24, 19, 0.035); opacity: 0; }

.tab {
  position: relative; flex: 1;
  display: grid; justify-items: center; align-content: center; gap: 3px;
  color: var(--muted);
  transition: color 0.3s ease;
  touch-action: none;
}
.tab:focus-visible { outline: none; }
.tab:focus-visible .tab__label { color: var(--ink); text-decoration: none; }
.tab:focus-visible .tab__icon { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 8px; }
.tab__icon { position: relative; width: 24px; height: 24px; display: block; }
.tab__icon svg { width: 24px; height: 24px; display: block; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tab__icon .fillable { fill: currentColor; fill-opacity: 0; transition: fill-opacity 0.3s ease; }
.tab.is-active { color: var(--ink); }
.tab.is-active .fillable { fill-opacity: 1; }
.tab--bag.is-active svg path:last-child { stroke: currentColor; }
.tab__label { font-size: 10.5px; font-weight: 560; letter-spacing: 0.005em; font-variation-settings: "wdth" 100; transition: font-variation-settings 0.3s ease; }
.tab.is-active .tab__label { font-weight: 660; font-variation-settings: "wdth" 108; }
.tab.is-dim { color: #bdb8ad; }
@media (hover: hover) {
  .tab:not(.is-active):hover { color: #57534a; }
}

/* the badge on the bag */
.badge {
  position: absolute; right: -8px; top: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 10px; font-weight: 700; line-height: 17px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface), 0 2px 4px -1px rgba(196, 83, 47, 0.5);
  overflow: hidden;
}
.badge__roll { display: block; }
.badge__n { display: block; height: 17px; }

/* the little grip above the Bag tab: you can pull here */
.grip { position: absolute; left: 0; top: 3px; width: 22px; height: 6px; pointer-events: none; display: grid; place-items: center; }
.grip span { width: 18px; height: 3px; border-radius: 3px; background: rgba(26, 24, 19, 0.16); }

/* ---- the drawn pointer of the autopilot ---- */
.ghost {
  position: fixed; left: 0; top: 0;
  width: 22px; height: 22px;
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
}
.ghost path { fill: #1a1813; stroke: #fff; stroke-width: 1.4; stroke-linejoin: round; }
