/* Get Less Chaos: A Place for Everything. Components.
   Every component is a PIECE (sits on the board, lifts in the hand, presses home), a POCKET (a cut with green
   showing), or a piece in its pocket. Hover lifts a piece to show its slot; press puts it home; focus seats it and
   draws the cut line. Needs tokens.css + base.css. Motion here is CSS-only; motion.js adds the choreographed moves. */

/* ================================================================ the two primitives */
.pocket {
  position: relative;
  border-radius: calc(var(--r, var(--radius-lg)) + var(--space-kerf));
  background: linear-gradient(var(--floor-top), var(--floor-bot));
  box-shadow: var(--z-sunk-2);
}
.pocket--empty { background: var(--board-2); } /* a neutral cut: nothing belongs here (yet) */
.piece {
  position: relative;
  border-radius: var(--r, var(--radius-lg));
  background: var(--piece);
  box-shadow: var(--z-flush);
}

@keyframes glc-thunk { /* pressed into the foam, the foam pushes back */
  from { transform: translateY(var(--sink, 3px)) scale(1.025, .955); }
  to { transform: none; }
}
@keyframes glc-seat { /* dropped in from where it was held, with its thunk (one curve) */
  from { transform: translate(var(--from-x, 0), var(--from-y, -28px)) rotate(var(--from-r, -2deg)); }
  to { transform: none; }
}
@keyframes glc-rim { /* the foam compressing around a piece as it goes home */
  from { box-shadow: var(--z-sunk-2), 0 0 0 0 var(--rim); }
  40% { box-shadow: var(--z-sunk-2), 0 0 0 2px var(--rim); }
  to { box-shadow: var(--z-sunk-2), 0 0 0 3px transparent; }
}

/* ================================================================ buttons: a piece in a finger-pull slot */
.btn {
  --piece-bg: var(--ink); --piece-fg: var(--board);
  position: relative; display: inline-flex; isolation: isolate; vertical-align: middle;
  border-radius: var(--radius-pill);
  background: none;
  text-decoration: none; color: var(--piece-fg);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  border: 0; padding: 0; font: inherit; cursor: pointer;
}
.btn::before { /* the slot: 1px inside the piece, so no green fringes at rest; the piece lifts to show it */
  content: ""; position: absolute; inset: 1px; z-index: -1; border-radius: inherit;
  background: linear-gradient(var(--floor-top), var(--floor-bot)); box-shadow: var(--z-sunk-1);
}
.btn__piece {
  position: relative; z-index: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  min-height: 48px; padding: .95em 1.5em .9em;
  border-radius: inherit;
  background: var(--piece-bg); color: var(--piece-fg);
  font-family: var(--font-text); font-size: var(--text-sm); font-weight: var(--weight-bold); line-height: 1; letter-spacing: .004em;
  white-space: nowrap;
  box-shadow: var(--z-flush);
  transform-origin: 62% 100%;
  transition: transform var(--dur-hover) var(--ease-spring), box-shadow var(--dur-hover) var(--ease-settle);
}
.btn__piece svg { width: 1.1em; height: 1.1em; flex: none; }
.btn--secondary { --piece-bg: var(--piece); --piece-fg: var(--ink); }
.btn--secondary .btn__piece { box-shadow: inset 0 0 0 1.5px var(--line), var(--z-flush); }
.btn--small .btn__piece { min-height: 40px; padding: .75em 1.15em .7em; font-size: var(--text-xs); }
@media (hover: hover) {
  .btn:hover .btn__piece { transform: translate(-1px, var(--lift-1-y)) rotate(var(--lift-1-r)); box-shadow: var(--z-lift-1); }
  .btn--secondary:hover .btn__piece { box-shadow: inset 0 0 0 1.5px var(--line), var(--z-lift-1); }
}
.btn:active .btn__piece {
  transform: translateY(var(--press-y)) scale(1.012, .965); box-shadow: var(--z-flush);
  transition-duration: var(--dur-press); transition-timing-function: var(--ease-drop);
}
.btn:focus-visible { outline-offset: 4px; border-radius: var(--radius-pill); }
.btn:focus-visible .btn__piece { animation: glc-thunk var(--dur-thunk) var(--ease-thunk) both; }
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; }
.btn:disabled::before, .btn[aria-disabled="true"]::before { background: var(--board-2); box-shadow: var(--z-cut-1); } /* an empty gray cut: nowhere to go yet */
.btn:disabled .btn__piece, .btn[aria-disabled="true"] .btn__piece {
  transform: none !important; box-shadow: var(--z-flush) !important; animation: none !important;
  --piece-bg: var(--board-2); color: var(--ink-3); box-shadow: inset 0 0 0 1.5px var(--line) !important;
}

/* ================================================================ text links in nav: a label that hops out of its groove */
.nav { display: flex; align-items: center; }
.nav ul { display: flex; align-items: center; gap: clamp(var(--space-2), 1.6vw, var(--space-5)); list-style: none; margin: 0; padding: 0; }
.nav__link {
  position: relative; display: inline-flex; align-items: center; height: 44px; padding: 0 var(--space-2);
  font-size: var(--text-sm); font-weight: 620; color: var(--ink-2); text-decoration: none; letter-spacing: .004em;
  border-radius: var(--radius-sm);
}
.nav__link::after { /* the groove: a little slot under the label */
  content: ""; position: absolute; left: var(--space-2); right: var(--space-2); bottom: 7px; height: 5px;
  border-radius: 3px;
  background: linear-gradient(var(--floor-top), var(--floor-bot));
  box-shadow: inset .5px 1.5px 0 -.5px var(--pocket-edge-a), inset 0 2px 3px -1px var(--pocket-ao-a), 0 1px 0 var(--lip-a);
  transform: scaleX(0); transform-origin: 0 50%;
  transition: transform var(--dur-hover) var(--ease-settle);
}
.nav__label { display: inline-block; white-space: nowrap; transition: transform var(--dur-hover) var(--ease-spring), color var(--dur-hover); }
@media (hover: hover) {
  .nav__link:hover { color: var(--ink); }
  .nav__link:hover::after { transform: scaleX(1); }
  .nav__link:hover .nav__label { transform: translateY(-3px) rotate(-2deg); }
}
.nav__link[aria-current="page"] { color: var(--ink); }
.nav__link[aria-current="page"]::after { transform: scaleX(1); }
.nav__link:active .nav__label { transform: translateY(1px); transition-duration: var(--dur-press); }

/* ================================================================ site header: the logo and the nav on the board */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--board) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.1) blur(10px); backdrop-filter: saturate(1.1) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-hover) var(--ease-settle);
}
.site-header.is-scrolled { border-bottom-color: var(--line); }
.site-header__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); height: 76px; }
.site-header .nav { padding-top: 14px; }
.brand { display: block; height: 40px; flex: none; border-radius: var(--radius-sm); -webkit-tap-highlight-color: transparent; }
.brand .glc-mini, .brand .glc-fallback { height: 100%; width: auto; display: block; }
.brand:focus-visible { outline-offset: 6px; border-radius: var(--radius-md); }
/* small screens: a "Menu" piece; the links drop into place as a sheet (motion.js GLCMotion.menu wires it)
   (r00: from 820px down, not 720: the final labels "Apps & games" and "How they’re built" need about 785px with the
   logo, and squeezed below that they wrapped onto two lines) */
.site-header__bar { position: relative; }
.nav__toggle { display: none; }
@media (max-width: 820px) {
  .nav__toggle { display: inline-flex; }
  .site-header .nav { padding-top: 0; }
  .nav ul {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60;
    flex-direction: column; align-items: stretch; gap: 2px; padding: var(--space-3);
    border-radius: var(--radius-lg); background: var(--piece); box-shadow: var(--z-lift-2);
    visibility: hidden; opacity: 0; transform-origin: 50% 0;
  }
  .nav.is-open ul { visibility: visible; opacity: 1; }
  .nav ul .nav__link { width: 100%; height: 52px; padding: 0 var(--space-4); font-size: var(--text-md); color: var(--ink); }
  .nav ul .nav__link::after { left: var(--space-4); right: auto; width: 2.2em; bottom: 9px; }
}
@media (max-width: 640px) {
  .site-header__bar { height: 64px; }
  .brand { height: 32px; }
  .site-header .nav { padding-top: 10px; }
  .nav__link { padding: 0 6px; font-size: var(--text-xs); }
  .nav__link::after { left: 6px; right: 6px; }
}

/* ================================================================ tags: label-maker tape */
.tag {
  --tape: var(--ink); --tape-fg: var(--board);
  display: inline-flex; align-items: center; gap: .45em;
  height: 24px; padding: 0 .65em 0 .7em;
  border-radius: 3px;
  background: var(--tape); color: var(--tape-fg);
  font-family: var(--font-label); font-variation-settings: "MONO" 1, "CASL" 0;
  font-size: 11.5px; font-weight: 640; letter-spacing: .1em; text-transform: uppercase; line-height: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), inset 0 -1px 0 rgba(0, 0, 0, .14), 0 1px 0 var(--lip-a);
  white-space: nowrap; vertical-align: middle;
}
/* Sample: ink on paper tape, with a thin stripe of the sample's color (the color itself lives only in the app's own slot) */
.tag--sample { --tape: var(--paper); --tape-fg: #16181B; text-shadow: none; transform: rotate(-1.2deg); padding-left: calc(.7em + 3px);
  box-shadow: inset 3px 0 0 var(--slot-marigold), inset 0 0 0 1px rgba(22, 24, 27, .14), 0 1px 0 var(--lip-a); }
.tag--foam { --tape: var(--foam); --tape-fg: var(--on-foam); text-shadow: 0 1px 0 rgba(255, 255, 255, .25); }
.tag--line { --tape: transparent; --tape-fg: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--line); text-shadow: none; }

/* ================================================================ app card: a tool in its foam cut */
.card {
  --r: var(--radius-lg);
  position: relative; display: block;
  border-radius: var(--r);
  background: linear-gradient(var(--floor-top), var(--floor-bot));
  box-shadow: var(--z-sunk-2);
  isolation: isolate;
}
.card__piece {
  position: relative; height: 100%;
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-6) var(--space-6) var(--space-5);
  border-radius: var(--r);
  background: var(--piece);
  box-shadow: var(--z-flush);
  transform-origin: 50% 100%;
  transition: transform calc(var(--dur-hover) * 1.4) var(--ease-spring), box-shadow var(--dur-hover) var(--ease-settle);
}
.card__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-3); }
.card__icon { width: 72px; height: 72px; border-radius: 18px; overflow: hidden; flex: none; box-shadow: 0 0 0 1px var(--piece-edge), 0 6px 14px -8px var(--lift-a); }
.card__icon svg { width: 100%; height: 100%; }
.card__name { font-size: var(--text-xl); }
.card__job { color: var(--ink-2); max-width: 34ch; }
.card__meta { margin-top: auto; padding-top: var(--space-4); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); font-size: var(--text-xs); color: var(--ink-3); }
.card__meta .label { letter-spacing: .04em; }
@media (hover: hover) {
  .card:hover .card__piece { transform: translateY(var(--lift-card-y)) rotate(var(--lift-card-r)); box-shadow: var(--z-lift-1); }
}
.card:focus-within .card__piece { transform: none; }
.card:has(:focus-visible) { outline: var(--ring-width) solid var(--ring); outline-offset: 4px; }
.card :focus-visible { outline-offset: 2px; }

/* the empty slot: a neutral cut the shape of a card, with one icon-shaped green pocket waiting for the next app */
.card--empty { min-height: 280px; display: grid; place-items: center; text-align: center; background: var(--board-2); box-shadow: var(--z-cut-2); }
.card--empty .card__hole { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-6); color: var(--ink-2); }
.card__slot {
  width: 72px; height: 72px; border-radius: 19px; margin-bottom: var(--space-3);
  background: linear-gradient(var(--floor-top), var(--floor-bot)); box-shadow: var(--z-sunk-2);
}
.card--empty .card__hole .label { font-size: var(--text-xs); letter-spacing: var(--tracking-label); text-transform: uppercase; font-weight: 640; color: var(--ink-3); }
.card--empty .card__hole strong { font-family: var(--font-display); font-weight: var(--weight-black); font-size: var(--text-xl); letter-spacing: var(--tracking-heading); line-height: 1.1; color: var(--ink); }

/* ================================================================ section head */
.section-head { display: grid; gap: var(--space-4); margin-bottom: var(--space-8); }
.section-head h2:has(.glyph--slot) { padding-top: .42em; }   /* room for the letter that waits above its slot */
.section-head h2 { max-width: 20ch; }
.section-head p { color: var(--ink-2); font-size: var(--text-lg); }

/* a letter of HTML text that waits above its own letter-shaped pocket (motion.js drops it in). With logo.js the
   pocket is cut from the logo's outlines (an svg behind the letter); without it, a flat green glyph stands in. */
.glyph { display: inline-block; position: relative; white-space: pre; }
.glyph--slot { isolation: isolate; }
.glyph--slot:not(.has-slot)::before {
  content: attr(data-ch); position: absolute; left: 0; top: 0; pointer-events: none; z-index: -1;
  color: var(--foam); text-shadow: 0 1px 0 var(--lip-a);
}
.glyph--slot.is-home::before { opacity: 0; }
.glyph--slot > .glyph__piece { display: inline-block; transform-origin: 18% 100%; }

/* ================================================================ panel: a big piece, seated flush on the board */
.panel { --r: var(--radius-xl); border-radius: var(--r); }
.panel__piece { height: 100%; border-radius: var(--r); background: var(--piece); box-shadow: var(--z-flush); padding: clamp(var(--space-6), 4vw, var(--space-8)); }

/* ================================================================ field: an empty required field is an empty slot */
.field { display: grid; gap: var(--space-2); }
.field label { font-size: var(--text-sm); font-weight: var(--weight-bold); }
.field input, .field textarea {
  width: 100%; min-height: 52px; padding: .9em 1em .85em; border: 0; border-radius: var(--radius-md);
  font-size: var(--text-md); color: var(--ink);
  background: linear-gradient(var(--floor-top), var(--floor-bot)); box-shadow: var(--z-sunk-1);
  transition: background-color var(--dur-hover), box-shadow var(--dur-hover);
}
.field input::placeholder { color: var(--on-foam); opacity: .72; }
.field input:not(:placeholder-shown) { background: var(--piece); box-shadow: inset 0 0 0 1.5px var(--line), var(--z-flush); animation: glc-seat 420ms var(--ease-seat) both; --from-y: -7px; --from-r: 0deg; }
.field input:focus-visible { outline-offset: 3px; border-radius: var(--radius-md); }
.field small { font-size: var(--text-xs); color: var(--ink-3); }

/* ================================================================ loaders */
.loader { display: inline-flex; align-items: center; gap: var(--space-3); font-size: var(--text-sm); color: var(--ink-3); }
.loader svg { height: 30px; width: auto; overflow: visible; }
/* CSS-only: three pieces drop into three slots in turn, over and over */
.loader-dots { display: inline-flex; gap: 6px; align-items: flex-end; height: 18px; }
.loader-dots i {
  position: relative; width: 12px; height: 8px; border-radius: 3px;
  background: linear-gradient(var(--floor-top), var(--floor-bot)); box-shadow: inset .5px 2px 0 -.5px var(--pocket-edge-a), 0 1px 0 var(--lip-a);
}
.loader-dots i::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--ink);
  animation: glc-dot 1.6s var(--ease-drop) infinite; animation-delay: calc(var(--i) * .2s);
}
@keyframes glc-dot {
  0%, 8% { transform: translateY(-11px) rotate(-8deg); opacity: 0; }
  12% { opacity: 1; }
  22% { transform: translateY(1px) scaleY(.85); animation-timing-function: var(--ease-thunk); }
  36%, 76% { transform: none; opacity: 1; }
  92%, 100% { transform: translateY(-11px) rotate(6deg); opacity: 0; }
}

/* ================================================================ footer: the bottom of the drawer */
.site-footer { padding-block: var(--space-8) var(--space-6); border-top: 1px solid var(--line); font-size: var(--text-sm); color: var(--ink-3); }
.site-footer__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-5); }
.site-footer__links { display: flex; flex-wrap: wrap; gap: var(--space-4); list-style: none; padding: 0; margin: 0; }
.site-footer__links a { color: var(--ink-2); text-decoration: none; }
.site-footer__links a:hover { color: var(--ink); text-decoration: underline 2px var(--foam); text-underline-offset: .3em; }
.site-footer .wink { font-family: var(--font-label); font-variation-settings: "MONO" 1, "CASL" 0; font-size: var(--text-xs); letter-spacing: .02em; }


/* ================================================================ switch: a piece that slides to the other end of its slot */
.switch {
  position: relative; display: inline-flex; align-items: center; gap: var(--space-3);
  border: 0; background: none; padding: 0; color: var(--ink-2); font-size: var(--text-sm); font-weight: 620; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.switch__slot {
  position: relative; width: 52px; height: 30px; flex: none; border-radius: var(--radius-pill);
  background: var(--board-2); box-shadow: var(--z-cut-1);
  transition: background-color var(--dur-hover) var(--ease-settle);
}
.switch__piece {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--piece); box-shadow: 0 0 0 1px var(--piece-edge), 0 3px 6px -2px var(--lift-a);
  transition: transform calc(var(--dur-hover) * 1.3) var(--ease-pop);
}
.switch[aria-checked="true"] .switch__slot { background: linear-gradient(var(--floor-top), var(--floor-bot)); box-shadow: var(--z-sunk-1); }
.switch[aria-checked="true"] .switch__piece { transform: translateX(22px); }
@media (hover: hover) { .switch:hover .switch__piece { box-shadow: 0 0 0 1px var(--piece-edge), 0 6px 10px -4px var(--lift-a); } }
.switch:active .switch__piece { transform: translateX(var(--sx, 0)) scale(1.08, .92); }
.switch[aria-checked="true"]:active .switch__piece { --sx: 22px; }
.switch:focus-visible { outline-offset: 4px; border-radius: var(--radius-pill); }

/* ================================================================ swatch chip (tokens on show) */
.chip { display: inline-flex; align-items: center; gap: var(--space-2); font-family: var(--font-label); font-variation-settings: "MONO" 1, "CASL" 0; font-size: var(--text-xs); color: var(--ink-2); }
.chip i { width: 18px; height: 18px; border-radius: var(--radius-xs); background: var(--c); box-shadow: inset 0 0 0 1px var(--piece-edge); }

@media (prefers-reduced-motion: reduce) {
  .btn:hover .btn__piece, .card:hover .card__piece, .nav__link:hover .nav__label { transform: none; }
  .btn:hover .btn__piece { box-shadow: var(--z-flush); }
  .tag--sample { transform: none; }
}
