/* IAHUH Digital Studio — styles.
   Colours of the moving background are set in index.html (data-colors). */

:root {
  --ink: #f6f2ea;            /* text */
  --base: #0b0b12;           /* behind the gradient */
  --serif: "Instrument Serif", "Times New Roman", serif;
  --mono: "DM Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--base);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Plain page (no JavaScript) ---------- */
.intro { max-width: 34rem; margin: 6rem auto -4rem; padding: 0 1.5rem; font-family: var(--mono); font-size: .85rem; line-height: 1.6; }
.js .intro { display: none; }
.plain { max-width: 34rem; margin: 7rem auto 6rem; padding: 0 1.5rem; list-style: none; }
.plain ul { list-style: none; padding: 0; }
.plain h2 { font-weight: 400; font-size: 2rem; margin: 2.5rem 0 .5rem; font-style: italic; }
.plain h3 { font-weight: 400; font-size: 1.3rem; margin: 1.2rem 0 .2rem; }
.plain p { font-family: var(--mono); font-size: .8rem; line-height: 1.6; margin: 0; opacity: .85; }
.stage, .bottom, .cursor, .crumbs { display: none; }

/* ---------- With JavaScript: full-screen map ---------- */
.js body { overflow: hidden; position: fixed; inset: 0; touch-action: none; }
.js .plain { display: none; }
.js .stage { display: block; }
.js .bottom { display: flex; }
.js .crumbs { display: flex; }

#bg {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  /* fallback when WebGL is missing */
  background:
    radial-gradient(60% 70% at 20% 25%, var(--c1, #5b2bff), transparent 70%),
    radial-gradient(55% 60% at 80% 30%, var(--c2, #ff3d6e), transparent 70%),
    radial-gradient(60% 60% at 60% 85%, var(--c3, #ffa53d), transparent 70%),
    var(--c0, #0b0b12);
}

.grain {
  position: fixed; inset: -120px; pointer-events: none;
  background-size: 240px 240px;
  opacity: .26;
  mix-blend-mode: overlay;
  animation: grain 1.6s steps(1) infinite;
}
@keyframes grain {
  0%   { transform: translate(0, 0); }
  17%  { transform: translate(-60px, 35px); }
  34%  { transform: translate(40px, -70px); }
  51%  { transform: translate(-25px, -40px); }
  68%  { transform: translate(70px, 55px); }
  85%  { transform: translate(-80px, -15px); }
}

/* ---------- Top bar ---------- */
.top {
  position: fixed; z-index: 5; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 22px 28px;
  padding-top: max(22px, env(safe-area-inset-top));
}
.logo img { display: block; height: 40px; width: auto; }
.contact, .crumbs, .count, .keys, .card-kicker, .card-tags, .card-link, .hint, .tick::after {
  font-family: var(--mono); font-weight: 400; font-size: 12px;
  letter-spacing: .1em; text-transform: uppercase;
}
.social { display: flex; gap: 22px; }
.contact { color: inherit; text-decoration: none; opacity: .8; transition: opacity .3s; white-space: nowrap; }
.contact:hover, .contact:focus-visible { opacity: 1; }

.crumbs { position: absolute; left: 50%; transform: translateX(-50%); gap: .6em; align-items: center; white-space: nowrap; }
.crumbs button {
  all: unset; cursor: pointer; opacity: .6; transition: opacity .3s;
}
.crumbs button:hover, .crumbs button:focus-visible, .crumbs button[aria-current] { opacity: 1; }
.crumbs span { opacity: .4; }

/* ---------- Map ---------- */
.stage { position: fixed; inset: 0; }
/* soft dark pool behind the map so the white labels read well */
.stage::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 60% 55% at 50% 50%, rgba(5, 5, 10, .28), transparent 75%);
}
.links { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.links path { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-linecap: round; }

.node {
  position: absolute; left: 0; top: 0;
  margin: 0; padding: 8px 10px; border: 0; background: none;
  color: inherit; font-family: var(--serif); font-weight: 400;
  line-height: 1.02; text-align: center; text-wrap: balance;
  cursor: pointer; will-change: transform, opacity;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 0 22px rgba(0, 0, 0, .45);
  -webkit-tap-highlight-color: transparent;
}
.node span { display: inline-block; transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.node:hover span { transform: scale(1.08); }
.node:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }
.node.branch { font-size: clamp(26px, 2.8vw, 40px); max-width: 7em; }
.node.leaf   { font-size: clamp(18px, 1.65vw, 24px); max-width: 8em; }
.node.on span { font-style: italic; }
.node.root {
  width: 104px; height: 104px; padding: 0; border-radius: 50%;
  border: 1px solid var(--ink);
  font-size: 27px; font-style: italic;
  transition: background .5s, color .5s;
}
.node.root:hover { background: var(--ink); color: #0b0b12; text-shadow: none; }
.node.root:hover span { transform: none; }

.hint {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  margin: 0; white-space: nowrap; pointer-events: none; opacity: 0;
}

/* ---------- Detail card ---------- */
.card {
  position: fixed; z-index: 6;
  right: 5vw; top: 50%;
  width: min(360px, 34vw);
  padding: 30px 30px 28px;
  background: rgba(10, 10, 16, .55);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .22);
  opacity: 0; transform: translate(18px, -50%); pointer-events: none;
  transition: opacity .5s, transform .7s cubic-bezier(.2, .8, .2, 1);
}
.card.show { opacity: 1; transform: translate(0, -50%); pointer-events: auto; }
.card-close {
  all: unset; position: absolute; top: 10px; right: 14px; cursor: pointer;
  font-family: var(--mono); font-size: 20px; line-height: 1; padding: 6px; opacity: .7;
}
.card-close:hover, .card-close:focus-visible { opacity: 1; }
.card-kicker { margin: 0 0 14px; opacity: .7; }
.card-title { margin: 0 0 14px; font-weight: 400; font-size: 34px; line-height: 1.02; text-wrap: balance; }
.card-text { margin: 0 0 18px; font-family: var(--mono); font-weight: 400; font-size: 13.5px; line-height: 1.65; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; padding: 0; list-style: none; font-size: 10px; }
.card-tags:empty { display: none; }
.card-tags li { padding: 4px 8px; border: 1px solid rgba(255, 255, 255, .35); border-radius: 99px; }
.card-link { color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 3px; }
.card-link:empty { display: none; }
.card-links { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.card-ask { opacity: .75; }
.card-ask:hover, .card-ask:focus-visible { opacity: 1; }
.card-link::after { content: " ↗"; }

/* ---------- Bottom: timeline ---------- */
.bottom {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; height: 64px;
  align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 28px; padding-bottom: env(safe-area-inset-bottom);
}
.count, .keys { opacity: .8; white-space: nowrap; min-width: 9em; }
.keys { text-align: right; }
.timeline { display: flex; align-items: center; gap: 6px; flex: 0 1 560px; min-width: 0; }
.step {
  all: unset; cursor: pointer; font-family: var(--mono); font-size: 20px;
  padding: 8px 10px; opacity: .7; transition: opacity .3s;
}
.step:hover, .step:focus-visible { opacity: 1; }
.ticks { display: flex; align-items: center; flex: 1; height: 44px; min-width: 0; }
.tick {
  all: unset; position: relative; cursor: pointer; flex: 1; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.tick i {
  display: block; width: 1px; height: 8px; background: var(--ink); opacity: .35;
  transition: height .4s cubic-bezier(.2, .8, .2, 1), opacity .4s, width .4s;
}
.tick.major i { height: 16px; }
.tick.seen i { opacity: .8; }
.tick:hover i, .tick:focus-visible i { opacity: 1; height: 22px; }
.tick.now i { opacity: 1; height: 28px; width: 2px; }
.tick::after {
  content: attr(data-label); position: absolute; bottom: 100%; left: 50%;
  transform: translate(-50%, 4px); white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .25s, transform .25s; font-size: 10px;
}
@media (hover: hover) {
  .tick:hover::after, .tick:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Cursor ring (mouse only) ---------- */
@media (hover: hover) and (pointer: fine) {
  .js .cursor {
    display: block; position: fixed; z-index: 9; left: 0; top: 0;
    width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
    border: 1px solid #fff; mix-blend-mode: difference; pointer-events: none; opacity: 0;
    transition: width .3s, height .3s, margin .3s, background .3s;
  }
  .js .cursor.big { width: 64px; height: 64px; margin: -32px 0 0 -32px; background: rgba(255, 255, 255, .12); }
}

/* ---------- Phones ---------- */
@media (max-width: 720px) {
  .top { padding: 16px 18px; }
  .logo img { height: 30px; }
  .social { gap: 14px; }
  .crumbs { top: 62px; font-size: 10px; }
  .node.branch { font-size: 27px; max-width: 6.2em; }
  .node.leaf { font-size: 18px; max-width: 7.5em; padding: 10px 8px; }
  .node.root { width: 86px; height: 86px; font-size: 23px; }
  .card {
    left: 12px; right: 12px; top: auto; bottom: 72px; width: auto;
    padding: 20px; transform: translateY(18px);
    max-height: 52vh; overflow-y: auto; background: rgba(10, 10, 16, .62);
  }
  .card.show { transform: none; }
  .card-title { font-size: 28px; }
  .card-text { font-size: 13px; margin-bottom: 14px; }
  .card-kicker, .card-title { margin-bottom: 10px; }
  .card-tags { margin-bottom: 16px; }
  .card-close { padding: 10px; top: 4px; right: 6px; }
  .hint { bottom: 76px; }
  .stage::before { background: radial-gradient(ellipse 85% 50% at 50% 50%, rgba(5, 5, 10, .3), transparent 75%); }
  .bottom { padding: 0 8px; height: 60px; }
  .keys { display: none; }
  .count { min-width: 0; padding-left: 8px; font-size: 11px; }
  .timeline { flex: 1; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .card, .node span, .tick i { transition: none; }
}
