/* Deck viewer. Warm dark greys so the decks are the colour (direction: .creative-agency/deck-viewer/direction.md).
   Motion values from the web-team study (hover-recipes, motion-values.md). */
:root {
  --ground: #121211;
  --side: #181816;
  --surface: #1f1f1d;
  --raised: #282825;
  --line: #2f2e2b;
  --text: #f3f1ec;
  --muted: #a8a49b;
  --faint: #928e85;
  --accent: #f1ead8;
  --star: #f4c55b;
  --focus: #8fb8ff;
  --hop-back: cubic-bezier(.34, 2.4, .64, 1);
  --out-soft: cubic-bezier(.16, 1, .3, 1);
  --swap: cubic-bezier(.34, 1.56, .64, 1);
  --radius: 12px;
  color-scheme: dark;
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ground); color: var(--text); }
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* Buttons */
.primary, .secondary, .ghost, .actions a {
  min-height: 44px; padding: 0 18px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; white-space: nowrap; transition: transform .18s var(--out-soft), background-color .18s var(--out-soft), border-color .18s var(--out-soft);
}
.primary { background: var(--accent); color: #151513; border: 1px solid var(--accent); font-weight: 600; }
.primary:hover { background: #fff; transform: translateY(-2px); transition: transform .28s var(--hop-back), background-color .18s var(--out-soft); }
.secondary, .actions a.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.secondary:hover { border-color: var(--muted); }
.ghost { background: transparent; border: 1px dashed var(--line); color: var(--muted); justify-content: flex-start; width: 100%; padding: 0 12px; }
.ghost:hover { color: var(--text); border-color: var(--muted); }
.link { background: none; border: 0; padding: 0 2px; min-height: 44px; display: inline-flex; align-items: center; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.link:hover { color: var(--text); text-decoration-color: var(--muted); }
.wide { width: 100%; }
.side #open { background: transparent; color: var(--text); border-color: #4a4842; font-weight: 600; }
.side #open:hover { border-color: var(--accent); background: var(--surface); }

/* Layout */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); height: 100dvh; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px; padding: 18px 14px 16px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; padding: 4px 6px 2px; letter-spacing: -0.01em; }
.mark { width: 22px; height: 16px; border-radius: 4px; background: linear-gradient(135deg, var(--accent), #c9bea3); position: relative; }
.mark::after { content: ""; position: absolute; left: 8px; top: 4px; border: 4px solid transparent; border-left: 7px solid #1a1a18; border-right: 0; }
.nav, .location-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav-item, .location-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); text-align: left; transition: background-color .18s var(--out-soft), color .18s var(--out-soft);
}
.location-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover, .location-item:hover { background: var(--surface); color: var(--text); }
.nav-item[aria-current], .location-item[aria-current] { background: var(--raised); color: var(--text); }
.side-head { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 0 10px 6px; }
.locations { display: grid; gap: 6px; }
.side-note { margin: 0 0 4px; padding: 0 10px; color: var(--faint); font-size: 13px; text-wrap: pretty; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); color: var(--faint); font-size: 13px; }
.side-foot p { margin: 0 0 4px; text-wrap: pretty; }
.side-foot .link { font-size: 13px; color: var(--faint); }

.home { overflow-y: auto; padding: 32px clamp(20px, 4vw, 56px) 64px; }
.view { max-width: 1080px; margin: 0 auto; display: grid; gap: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.section-head.big { margin-bottom: 0; align-items: center; }
.section-head h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.empty { margin: 0; color: var(--faint); text-wrap: pretty; max-width: 52ch; }

/* Drop zone: the biggest target on the page; the whole window also takes a drop. */
.drop-zone {
  display: grid; justify-items: center; text-align: center; gap: 6px; padding: 44px 24px 40px; cursor: pointer;
  border: 1.5px dashed #45433e; border-radius: 18px; background: linear-gradient(180deg, #1a1a18, #161615);
  transition: transform .46s var(--swap), border-color .18s var(--out-soft), background-color .18s var(--out-soft);
}
.drop-zone:hover { border-color: #5b5850; }
.drop-zone.over { border-color: var(--accent); border-style: solid; background: #22211e; transform: scale(1.012); }
.drop-icon svg { width: 44px; height: 44px; stroke-width: 1.3; color: var(--muted); }
.drop-zone.over .drop-icon svg { color: var(--accent); }
.drop-title { font-size: 21px; font-weight: 650; letter-spacing: -0.01em; margin-top: 4px; }
.drop-body { color: var(--muted); }
.drop-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.slides-form { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.slides-form label { font-size: 13px; color: var(--muted); grid-row: 1; }
.slides-form input { grid-row: 2; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--ground); color: var(--text); font: inherit; min-width: 0; }
.slides-form input:focus-visible { border-color: var(--focus); }
.form-error { grid-column: 1 / -1; margin: 2px 0 0; color: #f0a58f; font-size: 13px; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.touch-only { display: none; }
@media (hover: none) { .touch-only { display: inline; } .pointer-only { display: none; } }
/* Once there are decks, the zone becomes a slim bar so Recent sits near the top; the whole window still takes a drop. */
.drop-zone.compact { grid-template-columns: auto 1fr auto; justify-items: start; text-align: left; align-items: center; gap: 2px 16px; padding: 14px 16px 14px 18px; border-radius: 14px; }
.drop-zone.compact .drop-icon { grid-row: span 2; }
.drop-zone.compact .drop-icon svg { width: 30px; height: 30px; }
.drop-zone.compact .drop-title { font-size: 16px; margin: 0; }
.drop-zone.compact .drop-body { font-size: 13px; grid-column: 2; }
.drop-zone.compact .drop-actions { grid-column: 3; grid-row: 1 / span 2; margin: 0; }
.drop-zone.compact.over { transform: scale(1.006); }

/* Favorites: cards with the cover */
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.deck-card { position: relative; }
.card-open {
  display: grid; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: left; overflow: hidden;
  transition: transform .18s var(--out-soft), border-color .18s var(--out-soft);
}
/* A small lift with no overshoot: the Hub's Nov 18 ruling took the bounce out of hovers. */
.card-open:hover { transform: translateY(-2px); border-color: #45433e; }
.cover { aspect-ratio: 16 / 9; background: var(--raised); display: grid; place-items: center; overflow: hidden; }
.cover img, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.blank { background: linear-gradient(135deg, #2b2a26, #1f1e1b); color: var(--faint); font-weight: 650; }
.cover.blank span { font-size: 40px; }
.card-text { display: grid; gap: 2px; padding: 12px 48px 14px 14px; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-text .name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.meta { color: var(--faint); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-card .star { position: absolute; right: 4px; bottom: 6px; }

/* Recent: rows */
.rows { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.deck-row { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.row-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 8px 10px 8px 6px;
  border: 0; background: transparent; text-align: left; border-radius: 10px; transition: background-color .18s var(--out-soft);
}
.row-open:hover { background: var(--surface); }
.thumb { width: 80px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; display: grid; place-items: center; background: var(--raised); flex: none; }
.thumb.file span { font-size: 13px; }
.row-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.when { color: var(--faint); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.star, .remove {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none; border: 0; border-radius: 10px; background: transparent; color: var(--faint);
}
.star:hover, .remove:hover { color: var(--text); background: var(--surface); }
.star[aria-pressed="true"] { color: var(--star); }
.star[aria-pressed="true"] svg { fill: currentColor; animation: pop .28s var(--hop-back); }
@keyframes pop { from { transform: scale(.7); } to { transform: scale(1); } }
.remove { font-size: 20px; line-height: 1; opacity: .45; transition: opacity .18s var(--out-soft); }
.deck-row:hover .remove, .remove:focus-visible { opacity: 1; }
@media (hover: none) { .remove { opacity: 1; } }

/* State card: over everything, with a scrim */
.card {
  position: fixed; inset: 50% auto auto 50%; transform: translate(-50%, -50%); width: min(440px, calc(100% - 32px)); z-index: 5;
  padding: 26px 26px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 30px 90px rgb(0 0 0 / .55);
}
body.carded::before { content: ""; position: fixed; inset: 0; background: rgb(10 10 9 / .62); z-index: 4; }
body.linked .app > :not(#card):not(#player), body.linked::before { display: none; }
body.linked.carded::before { display: block; background: var(--ground); }
.card:focus { outline: none; }
.card h1 { margin: 0 0 8px; font-size: 21px; line-height: 1.25; font-weight: 650; text-wrap: balance; }
.card p { margin: 0; color: var(--muted); text-wrap: pretty; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.actions:empty { display: none; }
.card[data-kind="loading"] h1::after { content: "…"; display: inline-block; animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .3; } }

/* Player */
body.playing .side, body.playing .home { display: none; }
#player { position: fixed; inset: 0; display: flex; flex-direction: column; background: #000; z-index: 3; }
#frame { flex: 1; min-height: 0; }
.notes { flex: 0 0 auto; max-height: 34vh; overflow: auto; padding: 14px 22px 18px; background: var(--side); border-top: 1px solid var(--line); }
.notes header { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; color: var(--muted); }
.notes header strong { color: var(--text); font-weight: 600; }
.notes header .link { margin-left: auto; }
#notes-body { font-size: clamp(18px, 2.2vw, 26px); line-height: 1.45; max-width: 70ch; white-space: pre-wrap; }
#notes-body .empty { color: var(--faint); font-size: 16px; }
#player:fullscreen .notes, #player:-webkit-full-screen .notes { display: none; }
#frame iframe { display: block; width: 100%; height: 100%; border: 0; background: #000; }
.bar { display: flex; align-items: center; gap: 2px; height: 56px; padding: 0 8px; background: var(--ground); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0); box-sizing: content-box; }
.bar button { min-height: 44px; min-width: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); }
.bar button:hover { background: var(--surface); }
.bar .bar-back { color: var(--muted); }
.bar .title { flex: 1; min-width: 0; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar .count { min-width: 5ch; text-align: center; font-variant-numeric: tabular-nums; }
#previous, #next { font-size: 24px; padding: 0; }
.bar #notes-btn[aria-pressed="true"] { background: var(--raised); }
.bar .star { color: var(--faint); }
.bar .star[aria-pressed="true"] { color: var(--star); }
#player:fullscreen .bar, #player:-webkit-full-screen .bar { display: none; }

/* Whole-window drop and the toast */
.drop { position: fixed; inset: 10px; z-index: 6; display: grid; place-items: center; border: 2px solid var(--accent); border-radius: 20px; background: rgb(18 18 17 / .82); font-size: 22px; font-weight: 650; pointer-events: none; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 7; display: flex; align-items: center; gap: 14px;
  width: max-content; max-width: calc(100% - 32px); padding: 10px 12px 10px 16px; border-radius: 12px; background: var(--raised); border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgb(0 0 0 / .45); animation: rise .28s var(--hop-back);
}
.toast .link { color: var(--text); font-weight: 600; }
@keyframes rise { from { transform: translate(-50%, 8px); } to { transform: translate(-50%, 0); } }

/* Phone: the sidebar becomes a header with the views as tabs; Locations follow below. */
@media (max-width: 760px) {
  /* The sidebar's parts join the page's own grid: header and tabs first, the shelf, then Locations and the note. */
  .app { grid-template-columns: 1fr auto; grid-template-areas: "brand open" "nav nav" "home home" "loc loc" "foot foot"; grid-template-rows: auto; height: auto; min-height: 100dvh; padding: 0 16px; column-gap: 12px; }
  .side { display: contents; }
  .brand { grid-area: brand; align-self: center; padding: 14px 0 0; }
  #open { grid-area: open; width: auto; margin-top: 12px; }
  .nav { grid-area: nav; grid-auto-flow: column; justify-content: start; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .nav-item { width: auto; padding: 0 14px; }
  .home { grid-area: home; overflow: visible; padding: 20px 0 32px; }
  .locations { grid-area: loc; padding: 20px 0 8px; border-top: 1px solid var(--line); }
  .locations .side-head, .locations .side-note { padding-left: 0; }
  .side-foot { grid-area: foot; margin: 12px 0 0; padding: 12px 0 calc(24px + env(safe-area-inset-bottom, 0px)); }
  .view { gap: 28px; }
  .drop-zone { padding: 28px 18px; }
  .drop-title { font-size: 19px; }
  .drop-actions { width: 100%; }
  .drop-actions > * { flex: 1 1 100%; }
  .slides-form { grid-template-columns: 1fr; }
  .slides-form label, .slides-form input { grid-row: auto; }
  .drop-zone.compact { grid-template-columns: auto 1fr; }
  .drop-zone.compact .drop-body { display: none; }
  .drop-zone.compact .drop-actions { grid-column: 1 / -1; grid-row: auto; width: 100%; margin-top: 10px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-text { padding: 10px 44px 12px 12px; }
  .thumb { width: 64px; }
  .when { display: none; }
  .bar .title { display: none; }
  .bar { justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .card-open:hover, .primary:hover, .drop-zone.over { transform: none; }
}
