/* ---------- Fonts ----------
   Drop your licensed font files into /fonts with these names
   (or edit the paths). If the files are missing, the browser
   falls back to Helvetica / Arial. */
@font-face {
  font-family: "Helvshtica";
  src: local("Helvshtica"),
       url("fonts/Helvshtica.woff2") format("woff2"),
       url("fonts/Helvshtica.woff") format("woff");
  font-display: swap;
}
@font-face {
  font-family: "Helvetica Now World";
  src: local("Helvetica Now World"), local("HelveticaNowWorld-Regular"),
       url("fonts/HelveticaNowWorld-Regular.woff2") format("woff2"),
       url("fonts/HelveticaNowWorld-Regular.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}

/* ---------- Tokens (taken from the poster) ----------
   Layout: deck of cards on the left, sticky "futures that already exist"
   sidebar with the growing mosaic on the right; stacked on phones. */
:root {
  color-scheme: dark;
  --black: #0b0a09;
  --panel: #14110e;
  --white: #ffffff;
  --cream: #f5ede3;
  --orange: #e0703c;
  --amber: #f0a43a;
  --green: #93ac74;
  --line: rgba(245, 237, 227, 0.18);
  --radius: 18px;
  --font-title: "Helvshtica", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-text: "Helvetica Now World", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  color: var(--cream);
  font-family: var(--font-text);
  background: var(--black) url("images/background.webp") center top / 1200px auto repeat;
}

/* ---------- Header ---------- */
.site-header img {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- Context (about the circles) ---------- */
.context {
  padding-block: 48px 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.context img {
  display: block;
  width: 100%;
  max-width: 843px;
  height: auto;
  margin: 0 auto;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1480px;
  margin: 0 auto;
  padding-block: 48px 64px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 40px;
  align-items: start;
}

main { min-width: 0; }

/* ---------- Intro ---------- */
.intro { margin-bottom: 40px; }

.intro p {
  margin: 0 0 24px;
  max-width: 44ch;
  font-size: 1.25rem;
  line-height: 1.45;
  color: var(--green);
  text-wrap: pretty;
}

.controls { display: flex; flex-wrap: wrap; gap: 12px; }

button { font: inherit; }

.controls button,
.sheet-actions button {
  font-size: 1rem;
  padding: 10px 22px;
  border-radius: 999px;
  border: 2px solid var(--amber);
  background: transparent;
  color: var(--amber);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.controls button:hover,
.controls button:focus-visible,
.sheet-actions button:hover,
.sheet-actions button:focus-visible,
.sheet-actions .solid {
  background: var(--amber);
  color: var(--black);
  outline: none;
}
.sheet-actions .solid:hover,
.sheet-actions .solid:focus-visible { background: var(--orange); border-color: var(--orange); }
.sheet-actions button:disabled { opacity: 0.5; cursor: wait; }

/* ---------- Deck ---------- */
.deck {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 28px;
}

.card {
  aspect-ratio: 16 / 9;
  max-width: 100%;
  perspective: 1200px;
  container-type: inline-size;
}

.flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.card.is-flipped .flipper { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

.face--back {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  cursor: pointer;
  background: var(--cream) url("images/card-back.webp") center / cover no-repeat;
  transition: transform 0.25s;
}
.face--back:hover { transform: translateY(-4px); }

.face--front {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.6em;
  padding: 5.5cqi 7cqi 9cqi;
  background: var(--black);
  color: var(--white);
  border: 1px solid var(--line);
}

/* invisible full-card button: click the question side to turn it back over */
.turn-back {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: var(--radius);
}

.face--front .num,
.face--front .q { position: relative; pointer-events: none; }

.face--front .num {
  font-size: clamp(11px, 3.8cqi, 15px);
  letter-spacing: 0.02em;
  color: var(--orange);
}

.face--front .q {
  margin: 0;
  font-family: var(--font-text);
  font-size: clamp(13px, 5.6cqi, 22px);
  line-height: 1.35;
}
/* longer questions get a slightly smaller size */
.face--front .q.is-long { font-size: clamp(12px, 4.5cqi, 18px); }

/* "this future already exists" triangle */
.exists {
  position: absolute;
  right: 3.5cqi;
  bottom: 3cqi;
  width: 12cqi;
  min-width: 34px;
  aspect-ratio: 240 / 184;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
/* the triangle itself is drawn on ::before so it can move without moving the label */
.exists::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("images/future-exists.png") center / contain no-repeat;
  transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1), filter 0.3s;
}
.exists:hover::before,
.exists:focus-visible::before {
  transform: translateY(-4px) rotate(-12deg) scale(1.18);
  filter: drop-shadow(0 4px 10px rgba(240, 164, 58, 0.45));
}
.exists:focus-visible { outline: none; }
.exists:active::before { transform: scale(0.92); }

/* tooltip label */
.exists::after {
  content: "This future already exists";
  position: absolute;
  right: calc(100% + 8px);
  bottom: 50%;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--amber);
  color: var(--black);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(6px, 50%);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.exists:hover::after,
.exists:focus-visible::after { opacity: 1; transform: translate(0, 50%); }

.turn-back:focus-visible,
.face--back:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 4px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: max(24px, env(safe-area-inset-top, 0px));
  min-width: 0;
}

.sidebar-inner {
  padding: 24px 22px 26px;
  border-radius: var(--radius);
  background: var(--black) url("images/background.webp") center / 900px auto repeat;
  border: 1px solid var(--line);
}

.sidebar h2 {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.6rem;
  line-height: 1.05;
  letter-spacing: -0.045em;
  color: var(--green);
  text-wrap: balance;
}

.count {
  margin: 6px 0 14px;
  font-family: var(--font-title);
  font-size: 4.5rem;
  line-height: 1;
  color: var(--orange);
  font-variant-numeric: tabular-nums;
}
.count.bump { animation: bump 0.5s ease; }
@keyframes bump { 40% { transform: scale(1.18); color: var(--amber); } }

.hint {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 18px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--cream);
  opacity: 0.85;
}
.hint img { width: 30px; height: auto; flex: none; margin-top: 2px; }

.mosaic {
  list-style: none;
  margin: 0;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--black);
  border-radius: 10px;
}

.mosaic li { aspect-ratio: 1; }

.mosaic .tile {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  cursor: pointer;
  background: url("images/tile.png") center / 112% no-repeat;
  transition: transform 0.2s;
}
/* turn every other tile a quarter so the triangles interlock like zellij */
.mosaic li:nth-child(even) .tile { rotate: 90deg; }
.mosaic .tile:hover,
.mosaic .tile:focus-visible { transform: scale(1.15); outline: none; position: relative; z-index: 1; }
.mosaic .tile.is-new { animation: tile-in 0.7s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes tile-in { from { transform: scale(0) rotate(-120deg); opacity: 0; } }

.mosaic .slot {
  margin: 14%;
  height: 72%;
  border: 1px dashed var(--line);
  border-radius: 50%;
}

.storage-note {
  margin: 14px 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
  opacity: 0.65;
}

/* ---------- Dialogs ---------- */
.sheet {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--black);
  color: var(--white);
  font-family: var(--font-text);
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(3px); }

.sheet-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--orange);
}
.sheet-eyebrow::before {
  content: "";
  width: 26px;
  aspect-ratio: 240 / 184;
  background: url("images/future-exists.png") center / contain no-repeat;
}

.sheet-question {
  margin: 0 0 22px;
  font-size: 1.3rem;
  font-weight: 400;
  line-height: 1.35;
  text-wrap: balance;
}

.sheet label,
.sheet h4 {
  display: block;
  margin: 0 0 6px;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--green);
}

.sheet textarea {
  display: block;
  width: 100%;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--white);
  font: inherit;
  font-size: 1rem;
  line-height: 1.45;
  resize: vertical;
}
.sheet textarea::placeholder { color: var(--cream); opacity: 0.4; }
.sheet textarea:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: transparent; }

.sheet-answer {
  margin: 0 0 18px;
  font-size: 1.02rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.sheet-error { margin: -6px 0 16px; color: var(--amber); font-size: 0.9rem; }

.sheet-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }

/* ---------- Footer ---------- */
.site-footer {
  padding-block: 32px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  text-align: center;
}
.site-footer a {
  font-family: var(--font-title);
  font-size: 1.6rem;
  color: var(--green);
  text-decoration: none;
}
.site-footer a:hover { color: var(--orange); }

/* ---------- Narrow screens ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .sidebar { position: static; order: -1; }
  .intro { margin-bottom: 0; }
  main { display: contents; }
  .intro { order: -2; }
  .mosaic { grid-template-columns: repeat(8, 1fr); }
}

@media (max-width: 600px) {
  .layout {
    padding-block: 32px 48px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .deck { gap: 18px; }
  .mosaic { grid-template-columns: repeat(6, 1fr); }
  .count { font-size: 3.5rem; }
  .sheet { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .flipper, .face--back, .exists, .mosaic .tile { transition: none; }
  .mosaic .tile.is-new, .count.bump { animation: none; }
}
