/* =========================================================================
   ON3 — the tagline keys (js/key-book.js)
   Create. Record. Gather. as one segmented control in the tagline: an ivory
   thumb glides behind the pressed word, and a quiet line under each word says
   what it covers. Each key books its space; Record asks which room.
   ========================================================================= */

/* Three keys on one line: the words plus each key's padding and the gaps
   come to ~19.6 times the font size, so the size follows the gutters. */
.hero-copy h1.cat-keys {
  position: relative; display: flex; flex-wrap: nowrap; gap: 0; width: max-content;
  padding: 0.1em; margin-bottom: 0.14em; border-radius: 999px;
  font-size: min(3.4rem, calc((100vw - 2 * max(16px, 2.4vw)) / 19.6));
  background: rgba(243, 234, 217, 0.045);
  box-shadow: inset 0 0 0 1px rgba(243, 234, 217, 0.1), inset 0 0.04em 0.12em rgba(0, 0, 0, 0.35);
}
.cat-key {
  --spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  position: relative; z-index: 1; flex: none; margin: 0; border: 0; background: none; color: var(--on-dark);
  font: inherit; letter-spacing: inherit; line-height: 1; cursor: pointer;
  padding: 0.34em 0.6em 0.32em; border-radius: 999px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; -webkit-user-select: none; user-select: none;
  transition: transform 420ms var(--spring), color 300ms ease;
}
.cat-key:active { transform: scale(0.955); transition-duration: 80ms; }
.cat-key:focus-visible { outline: 2px solid var(--amber); outline-offset: 0.12em; }
.cat-key[aria-pressed="true"] { color: var(--espresso); }
.cat-key__t { position: relative; z-index: 1; display: block; transition: color 300ms ease; }

/* The ivory thumb sits behind the chosen key and glides between them. */
.cat-keys__thumb {
  display: block; position: absolute; z-index: 0; top: 0.1em; bottom: 0.1em; left: var(--thumb-x, 0); width: var(--thumb-w, 0);
  border-radius: 999px; background: linear-gradient(180deg, #f8f1e5, #e8dbc4);
  box-shadow: 0 0.05em 0.14em rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  opacity: 0; transition: left 460ms cubic-bezier(0.3, 1.25, 0.5, 1), width 460ms cubic-bezier(0.3, 1.25, 0.5, 1), opacity 240ms ease;
}
h1[data-on] .cat-keys__thumb { opacity: 1; }
h1.is-placing .cat-keys__thumb { transition: opacity 240ms ease; }

/* The scroll light (css/header.css) lights the keys one at a time, like the line
   under them: each comes up over about one and a half words' worth of scroll
   as --lit passes it. A chosen key is always fully lit. */
.hero-copy.is-lit-live h1.cat-keys { color: inherit; }
.cat-key:nth-of-type(1) { --i: 0; }
.cat-key:nth-of-type(2) { --i: 1; }
.cat-key:nth-of-type(3) { --i: 2; }
.hero-copy.is-lit-live .cat-key__t, .hero-copy.is-lit-live .cat-key__s {
  opacity: calc(0.18 + 0.82 * clamp(0, (var(--lit, 1) * 4.5 - var(--i)) / 1.5, 1));
}
.hero-copy.is-lit-live .cat-key[aria-pressed="true"] :is(.cat-key__t, .cat-key__s) { opacity: 1; }

/* ---- the line under each word
   It never widens its key (width 0, at least the key's width) and wraps if it must. */
.cat-key__s {
  position: relative; z-index: 1; display: block; width: 0; min-width: 100%;
  margin-top: 0.55em; font-family: var(--f-body);
  font-size: max(10px, 0.24em); line-height: 1.2; letter-spacing: 0.01em; text-align: center;
  white-space: normal; text-wrap: balance;
  color: var(--on-dark-dim); transition: color 300ms ease;
}
.cat-key[aria-pressed="true"] .cat-key__s { color: rgba(42, 29, 23, 0.72); }

/* On phones the keys are only just wider than their words, so the line may run
   into the key's side padding (but never past it) rather than break in two. */
@media (max-width: 600px) {
  .cat-key__s { margin-inline: -7px; min-width: calc(100% + 14px); }
}

@media (hover: hover) {
  .cat-key:not([aria-pressed="true"]):hover { color: #fff; }
  .cat-key:not([aria-pressed="true"]):hover .cat-key__s { color: var(--on-dark); }
}
@media (prefers-reduced-motion: reduce) {
  .cat-key, .cat-keys__thumb { transition: none; }
}

/* The smallest phones: the line under each word steps down a size so it stays on one line. */
@media (max-width: 350px) { .cat-key__s { font-size: 9px; letter-spacing: 0; } }

/* Pressing a key glides the gallery heading to just under the header. */
.gal-head { scroll-margin-top: 64px; }

/* ------------------------------------------------------------- Record: which room?
   A sheet rises from the bottom with the two rooms (js/key-book.js). Two cards side
   by side; on the narrowest phones, and on a phone turned sideways, each card is a
   row instead so both fit without scrolling. */
.kb-sheet {
  position: fixed; inset: auto 0 0 0; width: 100%; max-width: 720px; margin: 0 auto; max-height: min(92dvh, 640px);
  padding: 0 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
  border: 0; border-radius: 22px 22px 0 0; background: #1f1714; color: var(--on-dark);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5); transition: transform 260ms var(--ease);
}
.kb-sheet.is-dragging { transition: none; }
.kb-sheet[open] { animation: kb-rise 420ms var(--ease); }
.kb-sheet::backdrop { background: rgba(8, 6, 5, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes kb-rise { from { transform: translateY(100%); } to { transform: none; } }
html:has(.kb-sheet[open]) { overflow: hidden; }
.kb-sheet__bar {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 22px 0 14px; background: inherit; touch-action: none; cursor: grab;
}
.kb-sheet__grip { position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: rgba(243, 234, 217, 0.25); }
.kb-sheet__h { margin: 0; font-family: var(--f-display); font-size: 1.25rem; }
.kb-sheet__h span { margin-left: 6px; font-family: var(--f-body); font-size: 0.875rem; color: var(--on-dark-dim); }
.kb-x {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(243, 234, 217, 0.08); color: var(--on-dark); font: inherit; font-size: 26px; line-height: 1; cursor: pointer;
}
.kb-x:hover { background: rgba(243, 234, 217, 0.16); }
.kb-x:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.kb-sheet:focus { outline: none; }
.kb-sheet__cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kb-card {
  display: grid; grid-template-rows: auto 1fr; overflow: hidden; border-radius: 14px; color: var(--on-dark); text-decoration: none;
  background: rgba(243, 234, 217, 0.05); border: 1px solid rgba(243, 234, 217, 0.08);
  -webkit-tap-highlight-color: transparent; transition: transform 200ms ease, border-color 200ms ease;
}
.kb-card:focus-visible { border-color: var(--amber); outline: none; }
@media (hover: hover) { .kb-card:hover { border-color: var(--amber); } }
.kb-card:active { transform: scale(0.98); }
.kb-card img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
.kb-card__body { display: grid; align-content: start; gap: 3px; padding: 10px 12px 12px; }
.kb-card__body b { font-weight: 500; }
.kb-card__body small { font-size: 0.75rem; line-height: 1.35; color: var(--on-dark-dim); }
.kb-card__body em { margin-top: 4px; font-style: normal; font-size: 0.8125rem; color: var(--amber-soft); }
@media (max-width: 379px), (max-height: 500px) and (orientation: landscape) {
  .kb-sheet__cards { grid-template-columns: 1fr; }
  .kb-card { grid-template-rows: none; grid-template-columns: 112px 1fr; }
  .kb-card img { height: 100%; aspect-ratio: auto; min-height: 84px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .kb-sheet__cards { grid-template-columns: 1fr 1fr; }
  .kb-sheet__bar { padding: 16px 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .kb-sheet, .kb-card { transition: none; }
  .kb-sheet[open] { animation: none; }
}
