/* For the homepage prototype home-d.html (prototypes A and C, which shared this, were removed; branch
   homepage-cards): tokens, links, the reel boxes and the court. The court
   rules are index.html's, unchanged. */

:root {
  --paper: #F5F3F0;
  --ink: #121212;
  --link: #756300;
  --red: #F42934;
  --cream: #F2E9D2;
  --panel-bg: #0E2B03;
  --score: #F3E17D;
  --display: "City Boy", system-ui, sans-serif;
  --text: "Pangram Sans Rounded", system-ui, sans-serif;
  --wght-500: 500;
  --wght-700: 700;
  --edge: 40px;
  --line: color-mix(in srgb, var(--ink) 15%, transparent);
  --soft: color-mix(in srgb, var(--ink) 68%, transparent);
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  transition: background-color 420ms ease-out, color 420ms ease-out;
  font-family: var(--text);
  font-weight: var(--wght-500);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; }

#page { max-width: 1520px; margin: 0 auto; padding: 24px var(--edge) 32px; }

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--link);
  cursor: pointer;
  transition: opacity 0.14s ease-out;
}
@media (hover: hover) { .link:hover { opacity: 0.7; } }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-weight: var(--wght-700);
  font-size: 15px;
  letter-spacing: -0.01em;
  transition: scale 0.14s ease-out;
}
.pill:active { scale: 0.96; }

#name {
  margin: 0;
  font-family: var(--display);
  text-transform: uppercase;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--name, var(--red));
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: color 0.25s ease-out;
}

.head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding-bottom: 14px;
  margin: 0 0 4px;
  border-bottom: 1px solid var(--line);
}
.head h2 {
  margin: 0;
  font-family: var(--display);
  text-transform: uppercase;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.02em;
}
.head p { margin: 0; font-size: 15px; color: var(--soft); text-align: right; }

/* ---- a reel in a box ------------------------------------------------
   .media is the box (any size); the project's reel is centred in it at its
   own ratio, over the project's colours, with the screenshot under it
   until the reel's script is in. */
.media {
  position: relative;
  overflow: clip;
  background:
    radial-gradient(circle at 22% 18%, color-mix(in srgb, var(--c1) 55%, transparent), transparent 62%),
    var(--c2);
  container-type: size;
  --pad: clamp(12px, 6.6cqw, 40px);
}
.shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease-out;
}
.shot.inset {
  inset: var(--pad);
  width: calc(100% - 2 * var(--pad));
  height: calc(100% - 2 * var(--pad));
  object-fit: contain;
}
.media.has-reel .shot { opacity: 0; }
.card-reel {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  width: min(calc(100cqw - 2 * var(--pad)), calc((100cqh - 2 * var(--pad)) * var(--reel-ratio, 1.5758)));
  opacity: 0;
  transition: opacity 0.3s ease-out;
}
.card-reel.is-in { opacity: 1; }
.card-reel.is-framed.is-live { box-shadow: 2px 2px 30px 10px #00000026; border-radius: 10px; }

.lock { flex-shrink: 0; }

/* ---- the court (index.html's rules) --------------------------------- */

#panel {
  position: relative;
  border-radius: 24px;
  overflow: clip;
  background: var(--panel-bg);
  transition: background-color 420ms ease-out;
  box-shadow: 1px 1px 1px #00000026;
  container-type: inline-size;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; touch-action: none; }
#loader {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background: var(--panel-bg);
  transition: opacity 260ms ease-out;
}
#loader[data-done] { opacity: 0; }
#hud {
  position: absolute;
  top: clamp(14px, 2.44cqw, 24px);
  left: clamp(14px, 2.44cqw, 24px);
  right: clamp(14px, 2.44cqw, 24px);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 400ms ease-out 200ms;
  font-family: var(--display);
  font-size: clamp(20px, 2.6cqw, 32px);
  line-height: 100%;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--score);
}
#panel[data-ready] #hud { opacity: 1; }
#newbest {
  position: absolute;
  left: 0;
  right: 0;
  top: 24%;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
  font-family: var(--display);
  font-size: clamp(30px, 5.4cqw, 72px);
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--score);
  text-shadow: 0 3px 0 #00000040;
}
#newbest.show { animation: nb-out 0.45s ease-in 1.9s forwards; }
#newbest .l {
  display: inline-block;
  animation: nb-in 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) backwards;
  animation-delay: calc(var(--i) * 30ms);
}
@keyframes nb-in { from { opacity: 0; transform: translateY(0.55em) scale(0.3) rotate(var(--r)); } }
@keyframes nb-out { to { opacity: 0; transform: translateY(-0.5em); } }
#hud .v.bump { display: inline-block; animation: nb-bump 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes nb-bump { 40% { transform: scale(1.4); } }
@keyframes nb-fade { from { opacity: 0; } }
@keyframes nb-fade-out { to { opacity: 0; } }
#games {
  position: absolute;
  left: 50%;
  bottom: clamp(14px, 2.44cqw, 24px);
  translate: -50% 0;
  z-index: 2;
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: #00000047;
  opacity: 0;
  transition: opacity 400ms ease-out 200ms;
}
#panel[data-ready] #games { opacity: 1; }
#games button {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 7px 12px 6px;
  border-radius: 999px;
  background: transparent;
  font-family: var(--display);
  font-size: 13px;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--score);
  opacity: 0.7;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.18s ease-out, color 0.18s ease-out, opacity 0.18s ease-out;
}
#games button:hover { opacity: 1; }
#games button[aria-pressed="true"] { background: var(--score); color: var(--panel-bg); opacity: 1; }
#games button:focus-visible { outline: 2px solid var(--score); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  #newbest .l { animation-name: nb-fade; animation-timing-function: ease-out; }
  #newbest.show { animation-name: nb-fade-out; }
  #hud .v.bump { animation: none; }
  .link, .shot, .card-reel, #hud, #games, #loader { transition: none; }
}

@media (max-width: 900px) { :root { --edge: 20px; } }

/* A clicked project's reel grows into its case study's hero (`reel` on both
   sides, named by home-proto.js's pageswap handler); the rest cross-fades. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-group(root),
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 0.2s; }
  ::view-transition-group(reel) { animation-duration: 0.3s; animation-timing-function: cubic-bezier(0.2, 0, 0, 1); }
}

h1, h2, h3 { text-wrap: balance; }
