/* ABOUTME: Styles for the AINC Build browser app in the AI Native Club design system. */
/* ABOUTME: Warm paper, Gambarino display + Supreme sans, dot grid, hard offset shadows, poster frame. */

@import url('https://api.fontshare.com/v2/css?f[]=gambarino@400&f[]=supreme@300,400,500,700&display=swap');

:root {
  color-scheme: light;

  /* AI Native Club palette - Humans in the Loop poster */
  --paper:       #F8E9DC;
  --paper-shade: #F2D4C5;
  --paper-edge:  #E8B9A7;
  --ink:         #181818;
  --ink-soft:    #261F1D;
  --ink-muted:   #6F4F45;
  --red:         #C8202A;
  --red-deep:    #7F1016;
  --clay:        #E86126;
  --gold:        #F6AA1C;
  --sky:         #2E6F91;

  --rule:      color-mix(in oklch, var(--ink) 20%, transparent);
  --rule-soft: color-mix(in oklch, var(--ink) 9%, transparent);

  --display: 'Gambarino', 'Times New Roman', serif;
  --sans: 'Supreme', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --phase-color: var(--ink-muted);
}

body[data-phase="focus"] { --phase-color: var(--red); }
body[data-phase="snack"] { --phase-color: var(--clay); }

*, *::before, *::after { box-sizing: border-box; }

html {
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 6%, color-mix(in oklch, var(--red) 14%, transparent) 0 170px, transparent 171px),
    radial-gradient(circle at 92% 10%, color-mix(in oklch, var(--clay) 18%, transparent) 0 140px, transparent 141px),
    radial-gradient(circle at 82% 78%, color-mix(in oklch, var(--gold) 15%, transparent) 0 190px, transparent 191px),
    radial-gradient(circle at 12% 86%, color-mix(in oklch, var(--sky) 12%, transparent) 0 150px, transparent 151px),
    radial-gradient(color-mix(in oklch, var(--ink) 7%, transparent) 0.75px, transparent 0.75px),
    var(--paper);
  background-size: auto, auto, auto, auto, 24px 24px, auto;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Poster frame around the viewport */
body::before {
  content: "";
  position: fixed;
  inset: 10px;
  border: 1px solid var(--rule);
  pointer-events: none;
  z-index: 60;
}

h1, h2, h3, p, ul { margin: 0; }
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
canvas { display: block; width: 100%; height: 100%; }

.shell {
  min-height: 100vh;
  min-height: 100svh;
  width: min(76rem, 100% - 3.5rem);
  margin: 0 auto;
  padding: 1.9rem 0 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 1.4rem;
}

/* ---------- Masthead ---------- */

.masthead {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--rule);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  white-space: nowrap;
}

.brand-logo {
  width: 3.1rem;
  height: 2.95rem;
  object-fit: contain;
  display: block;
}

.wordmark-sep {
  color: var(--red);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}

.wordmark-app {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  padding: 0.18rem 0.5rem 0.12rem;
  background: var(--ink);
  color: var(--paper);
}

.conn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.conn-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--ink-muted);
  transition: background 300ms var(--ease-out);
}

body[data-conn="open"] .conn-dot { background: var(--sky); }
body[data-conn="connecting"] .conn-dot {
  background: var(--gold);
  animation: conn-pulse 1s ease-in-out infinite;
}

@keyframes conn-pulse {
  50% { opacity: 0.35; }
}

.mac-link {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-decoration: none;
  border: 1px solid var(--rule);
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  transition: background 180ms var(--ease-out), color 180ms var(--ease-out);
}

.mac-link:hover { background: var(--ink); color: var(--paper); }

/* ---------- Shared bits ---------- */

.eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--red);
}

.btn {
  --btn-bg: transparent;
  min-height: 2.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0 1.3rem;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--btn-bg);
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background 140ms var(--ease-out),
    color 140ms var(--ease-out), box-shadow 140ms var(--ease-out), border-color 140ms var(--ease-out);
}

.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 3px 0 var(--rule); }
.btn:active:not(:disabled) { transform: translateY(0); box-shadow: none; }
.btn:disabled { cursor: not-allowed; opacity: 0.35; }

.btn-primary {
  --btn-bg: var(--red);
  border-color: var(--red);
  color: var(--paper);
}

.btn-primary:hover:not(:disabled) { --btn-bg: var(--red-deep); border-color: var(--red-deep); }

.btn-outline { color: var(--ink); }
.btn-outline:hover:not(:disabled) { background: var(--ink); color: var(--paper); }

.btn-quiet {
  border-color: var(--rule);
  color: var(--ink-muted);
}

.btn-big { min-height: 3.4rem; padding: 0 2rem; font-size: 0.98rem; }

.btn-mini {
  min-height: 2rem;
  padding: 0 0.75rem;
  font-size: 0.72rem;
  border-width: 1px;
}

/* ---------- Join stage ---------- */

.join-stage {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(1.5rem, 5vw, 4.5rem);
  align-items: center;
  padding: clamp(0.5rem, 3vh, 2rem) 0;
}

.join-copy { display: grid; gap: 1.1rem; justify-items: start; }

.join-copy h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.2rem, 8.5vw, 6.4rem);
  line-height: 0.98;
  letter-spacing: -0.01em;
}

.join-copy .accent { color: var(--red); }

.lede {
  max-width: 34ch;
  font-size: 1.08rem;
  color: var(--ink-soft);
}

.join-figure {
  width: clamp(120px, 16vw, 180px);
  aspect-ratio: 10 / 13;
  margin-top: 0.4rem;
}

.join-card {
  display: grid;
  gap: 1rem;
  padding: clamp(1.4rem, 3vw, 2.2rem);
  background: color-mix(in oklch, var(--paper) 55%, white);
  border: 1px solid var(--ink);
  box-shadow: 8px 8px 0 color-mix(in oklch, var(--ink) 14%, transparent);
  transform: rotate(-0.6deg);
}

.join-card-title {
  font-family: var(--display);
  font-size: 1.6rem;
  line-height: 1.1;
}

.field { display: grid; gap: 0.4rem; }

.field span {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
}

input {
  width: 100%;
  min-height: 3rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0 0.9rem;
  background: white;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}

input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 3px 3px 0 color-mix(in oklch, var(--gold) 55%, transparent);
}

#roomCode {
  font-family: var(--display);
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
}

.button-col { display: grid; gap: 0.6rem; margin-top: 0.3rem; }

/* ---------- Room stage ---------- */

.room-stage {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  grid-template-areas:
    "bar bar"
    "clock figure"
    "controls controls";
  gap: clamp(1rem, 2.5vw, 2rem);
  align-content: start;
  padding-top: 0.4rem;
}

.room-bar {
  grid-area: bar;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.8rem;
}

.room-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.4rem 0.6rem 0.4rem 1rem;
  background: color-mix(in oklch, var(--paper) 55%, white);
}

.room-chip-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
}

.room-chip strong {
  font-family: var(--display);
  font-size: 1.25rem;
  letter-spacing: 0.22em;
}

.people-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0;
  margin-left: auto;
  list-style: none;
}

.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.32rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 500;
  background: color-mix(in oklch, var(--paper) 55%, white);
}

.person-avatar,
.orbit-avatar {
  --avatar-color: var(--sky);
  display: inline-grid;
  place-items: center;
  color: white;
  background:
    radial-gradient(circle at 30% 25%, color-mix(in oklch, white 38%, transparent) 0 18%, transparent 19%),
    var(--avatar-color);
  border: 1.5px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink), 0 3px 0 color-mix(in oklch, var(--ink) 13%, transparent);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.person-avatar {
  width: 1.65rem;
  height: 1.65rem;
  flex: 0 0 auto;
  border-radius: 50%;
  font-size: 0.7rem;
}

/* Clock */

.clock-column {
  grid-area: clock;
  display: grid;
  gap: 0.85rem;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.phase-line {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--phase-color);
}

.phase-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--phase-color);
}

body[data-running="true"] .phase-dot { animation: conn-pulse 2s ease-in-out infinite; }

.timer-orbit {
  --progress-deg: 0deg;
  width: min(100%, clamp(19rem, 43vw, 34rem));
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
}

.timer-ring {
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  padding: clamp(0.52rem, 1.3vw, 0.82rem);
  background:
    conic-gradient(var(--phase-color) var(--progress-deg), var(--rule-soft) 0deg);
  border: 1px solid var(--rule);
  transition: background 300ms linear;
}

.timer-core {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in oklch, var(--paper) 78%, white);
  border: 1px solid color-mix(in oklch, var(--ink) 16%, transparent);
  box-shadow: inset 0 0 0 6px color-mix(in oklch, var(--paper-shade) 38%, transparent);
}

.clock {
  font-family: var(--display);
  font-size: clamp(4.2rem, 9.5vw, 7.4rem);
  line-height: 0.92;
  letter-spacing: 0;
  display: flex;
  align-items: baseline;
  user-select: none;
}

.clock .digit {
  display: inline-block;
  width: 0.56em;
  text-align: center;
}

.clock .colon {
  display: inline-block;
  width: 0.3em;
  text-align: center;
  color: var(--phase-color);
}

body[data-running="true"] .clock .colon { animation: colon-blink 1s steps(1) infinite; }

@keyframes colon-blink {
  50% { opacity: 0.25; }
}

.orbit-avatars {
  position: absolute;
  inset: 0;
  padding: 0;
  margin: 0;
  list-style: none;
  pointer-events: none;
}

.orbit-avatar {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(2.35rem, 5.4vw, 3.2rem);
  height: clamp(2.35rem, 5.4vw, 3.2rem);
  border-radius: 50%;
  font-size: clamp(0.78rem, 1.7vw, 1rem);
  transform: translate(-50%, -50%) scale(1);
  transition: left 320ms var(--ease-out), top 320ms var(--ease-out),
    transform 180ms var(--ease-out), background 180ms var(--ease-out);
}

body[data-running="true"] .orbit-avatar {
  animation: avatar-breathe 2.8s ease-in-out infinite;
  animation-delay: calc(var(--avatar-index, 0) * -180ms);
}

@keyframes avatar-breathe {
  50% { transform: translate(-50%, -50%) scale(1.06); }
}

.timer-detail {
  font-size: 0.95rem;
  color: var(--ink-muted);
}

/* Figure card */

.figure-card {
  grid-area: figure;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.6rem;
  padding: 1.1rem 1.1rem 1.2rem;
  border: 1px solid var(--ink);
  background: color-mix(in oklch, var(--paper) 55%, white);
  box-shadow: 8px 8px 0 color-mix(in oklch, var(--ink) 14%, transparent);
  transform: rotate(0.5deg);
  transition: background 500ms var(--ease-out);
  min-height: 20rem;
  overflow: hidden;
}

body[data-phase="snack"] .figure-card {
  background: color-mix(in oklch, var(--gold) 20%, var(--paper));
}

.figure-card canvas {
  height: clamp(13rem, 34svh, 24rem);
  min-height: 0;
}

.figure-caption { display: grid; gap: 0.2rem; text-align: center; }

.figure-title {
  font-family: var(--display);
  font-size: 1.45rem;
  line-height: 1.1;
}

.figure-cue {
  font-size: 0.92rem;
  color: var(--ink-soft);
  min-height: 2.7em;
  transition: opacity 250ms var(--ease-out);
}

.figure-cue.swap { opacity: 0; }

/* Controls */

.controls {
  grid-area: controls;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  padding-top: 0.4rem;
}

.controls .btn-primary { flex: 1.4 1 10rem; }
.controls .btn-outline,
.controls .btn-quiet { flex: 1 1 8rem; }

/* ---------- Ticker footer ---------- */

.ticker {
  position: relative;
  display: flex;
  align-items: center;
  border-top: 1px solid var(--rule);
  padding: 0.55rem 0 0.9rem;
  overflow: hidden;
  white-space: nowrap;
}

.ticker-track {
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--ink-muted);
  animation: ticker-roll 36s linear infinite;
}

@keyframes ticker-roll {
  to { transform: translateX(-50%); }
}

.revision {
  position: absolute;
  right: 0;
  top: 0.55rem;
  font-size: 0.68rem;
  color: color-mix(in oklch, var(--ink-muted) 60%, transparent);
  background: var(--paper);
  padding-left: 0.6rem;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: 1.6rem;
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(90vw, 30rem);
  padding: 0.65rem 1.3rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: 0 10px 30px color-mix(in oklch, var(--ink) 30%, transparent);
}

.toast.error { background: var(--red-deep); }

.toast[hidden] { display: none; }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .shell {
    width: min(100% - 2rem, 44rem);
    padding-top: 1.1rem;
    gap: 0.95rem;
  }

  body::before { inset: 6px; }

  .masthead { flex-wrap: wrap; row-gap: 0.4rem; }
  .conn { order: 3; margin-left: 0; width: 100%; }

  body[data-room="active"] .masthead { align-items: center; }
  body[data-room="active"] .conn {
    order: 0;
    width: auto;
    margin-left: auto;
  }
  body[data-room="active"] .mac-link,
  body[data-room="active"] .ticker {
    display: none;
  }

  .join-stage { grid-template-columns: 1fr; gap: 1.8rem; }
  .join-card { transform: none; }
  .join-figure { display: none; }

  .room-stage {
    grid-template-columns: 1fr;
    grid-template-areas: "bar" "clock" "figure" "controls";
    gap: 0.85rem;
  }

  .people-list { margin-left: 0; width: 100%; }

  .brand-logo {
    width: 2.55rem;
    height: 2.45rem;
  }

  .timer-orbit {
    width: min(100%, 22.5rem);
  }

  .clock { font-size: clamp(3.2rem, 15vw, 5rem); }

  .figure-card {
    min-height: 0;
    padding: 0.9rem 0.9rem 1rem;
    transform: none;
  }

  .figure-card canvas {
    height: clamp(8.5rem, 24svh, 12.5rem);
  }

  .figure-title { font-size: 1.2rem; }

  .figure-cue {
    min-height: 2.4em;
    font-size: 0.84rem;
  }

  .controls .btn-primary { flex: 1 1 100%; }
  .controls .btn-outline,
  .controls .btn-quiet { flex: 1 1 calc(50% - 0.4rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
  .ticker-track { animation: none; }
}
