/* Components — spec §3 */

/* 3.1 Button */
.btn {
  font-family: var(--font-ui);
  cursor: pointer;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  transition: background .2s ease, transform .2s ease, border-color .2s ease;
  color: var(--text-1);
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] {
  background: var(--surface);
  color: var(--text-3);
  cursor: not-allowed;
  pointer-events: none;
}
.btn--primary {
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--r-pill);
  background: var(--accent-fill);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.btn--ghost {
  padding: 10px 18px;
  font-size: 14px;
  border-radius: var(--r-pill);
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
}
.btn--ghost:hover { background: var(--surface-hover); color: var(--text-1); }
.btn--icon {
  width: 44px; height: 44px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text-1);
}
.btn--icon:hover { background: var(--surface-hover); }
.btn--icon.is-on { background: var(--accent-fill); border-color: var(--accent-border); color: var(--accent); }

/* 3.2 Chip */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  font-family: var(--font-ui);
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.chip:hover { background: var(--surface-hover); }
.chip[aria-checked="true"] {
  background: var(--accent-fill);
  border-color: var(--accent-border);
  color: var(--accent);
}
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 3.3 Toggle */
.toggle {
  width: 46px; height: 26px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  position: relative;
  cursor: pointer;
  padding: 0;
  transition: background .2s ease, border-color .2s ease;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 50%; left: 4px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-2);
  transform: translateY(-50%);
  transition: transform .2s ease, background .2s ease;
}
.toggle[aria-checked="true"] { background: var(--accent-fill); border-color: var(--accent-border); }
.toggle[aria-checked="true"]::after { transform: translate(20px, -50%); background: var(--accent); }
.toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 3.4 Slider */
.field { display: flex; align-items: center; gap: var(--sp-3); }
.field label { color: var(--text-2); font-size: var(--fs-small); min-width: 52px; }
input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
}

/* 3.5 Presence pill */
.presence {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text-2);
  font-size: var(--fs-small);
}
.presence .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.presence b { color: var(--text-1); font-weight: 500; }
/* honest-offline: reconnecting state — quiet, dimmed, dot pulses (no red/toast) */
.presence.is-stale { color: var(--text-3); opacity: 0.6; }
.presence.is-stale .dot { background: var(--text-3); }
@media (prefers-reduced-motion: no-preference) {
  .presence.is-stale .dot { animation: presencePulse 1.6s ease-in-out infinite; }
}
@keyframes presencePulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* 3.6 Reaction */
.reactions { display: flex; gap: var(--sp-2); justify-content: center; }
.react {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.react:hover { background: var(--surface-hover); }
.react:active { transform: scale(.92); }
.react svg { width: 20px; height: 20px; }
/* floating reaction layer */
.float-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.float {
  position: absolute;
  bottom: 0;
  pointer-events: none;
  will-change: transform, opacity;
}
@media (prefers-reduced-motion: no-preference) {
  .float { animation: floatUp 4s ease-out forwards; }
}
@keyframes floatUp {
  0%   { transform: translateY(0) scale(.8); opacity: 0; }
  15%  { opacity: .9; }
  100% { transform: translateY(-220px) scale(1.1); opacity: 0; }
}

/* 3.7 To-do (Focus) */
.todo { display: flex; flex-direction: column; gap: var(--sp-2); width: 100%; }
.todo-row { display: flex; align-items: center; gap: var(--sp-3); }
.todo-add { display: flex; gap: var(--sp-2); }
.todo-add input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 9px 12px;
}
.todo-add input::placeholder { color: var(--text-3); }
.todo-add input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check {
  width: 19px; height: 19px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.check[aria-checked="true"] { background: var(--done); border-color: var(--done); }
.check svg { width: 12px; height: 12px; opacity: 0; color: #0E0F1A; }
.check[aria-checked="true"] svg { opacity: 1; }
.todo-label { font-size: 14px; line-height: 1.35; }
.todo-row[data-done="true"] .todo-label { color: var(--text-3); text-decoration: line-through; }
.todo-empty { color: var(--text-3); font-size: var(--fs-small); padding: var(--sp-2) 0; }

/* 3.8 Breathing circle (Calm) */
.breath { position: relative; width: 200px; height: 200px; display: grid; place-items: center; }
.breath .ring {
  position: absolute;
  width: 170px; height: 170px;
  border-radius: 50%;
  border: 1px solid var(--accent-border);
  opacity: .4;
}
.breath .core {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: var(--accent-fill);
  border: 1px solid var(--accent-border);
  display: grid; place-items: center;
  text-align: center;
  transform: scale(.55);
}
@media (prefers-reduced-motion: no-preference) {
  .breath .core { transition: transform 4s ease-in-out; }
}
@media (prefers-reduced-motion: reduce) {
  .breath .core { transform: scale(.85) !important; }
}
.breath .phase { font-family: var(--font-display); font-size: 17px; color: var(--accent); }
.breath .count { font-size: var(--fs-small); color: var(--text-2); margin-top: 2px; }
/* halo on each bell (§5) */
.halo {
  position: absolute;
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .halo { animation: halo 1.6s ease-out forwards; }
}
@keyframes halo {
  0%   { opacity: .5; transform: scale(.95); }
  100% { opacity: 0;  transform: scale(1.35); }
}

/* 3.9 Pomodoro ring (Focus) */
.pomo { position: relative; width: 150px; height: 150px; display: grid; place-items: center; }
.pomo svg { transform: rotate(-90deg); }
.pomo .bg-ring { stroke: rgba(255,255,255,.08); }
.pomo .fg-ring { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke .4s ease; }
.pomo .center { position: absolute; text-align: center; }
.pomo .time { font-family: var(--font-display); font-size: 28px; line-height: 1; }
.pomo .round { font-size: var(--fs-micro); color: var(--text-3); margin-top: 4px; }
.pomo-tag { color: var(--text-2); font-size: var(--fs-small); }

/* Lobby + room cards (navigation: lobby → space → sub-room) */
.lobby { display: flex; flex-direction: column; gap: var(--sp-2); padding-top: var(--sp-4); }
.lobby-hero h1 { font-size: 30px; margin-bottom: var(--sp-1); }
.lobby-hero p { margin: 0; max-width: 36ch; }
.room-list { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-2); }
.room-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  text-align: left;
  padding: var(--sp-3);
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text-1);
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.room-card:hover { background: var(--surface-hover); border-color: var(--accent-border); }
.room-card:active { transform: scale(.99); }
.room-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.room-card-art {
  width: 52px; height: 52px;
  border-radius: var(--r-md);
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 25%, #211d33));
}
.room-card-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.room-card-name { font-size: 16px; font-weight: 500; }
.room-card-desc { font-size: var(--fs-small); color: var(--text-2); }
.room-card-go { color: var(--text-3); flex-shrink: 0; }
.room-card-go svg { width: 20px; height: 20px; }

/* Room header */
.room-head { padding: var(--sp-3) 0 0; }
.room-title { font-family: var(--font-display); font-size: 22px; }
.room-sub { margin-top: 2px; }

/* ============ Desktop identity: "aurora glow minimalism" ============
   Big type, glowing orb tiles, two-column room. Mobile stays untouched. */
@media (min-width: 1024px) {
  /* --- Lobby: hero + grid of orb tiles --- */
  .lobby { padding-top: 56px; gap: var(--sp-4); }
  .lobby-hero h1 {
    font-size: 64px;
    letter-spacing: -0.5px;
    line-height: 1.05;
    background: linear-gradient(92deg, var(--text-1) 35%, var(--accent) 90%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  .lobby-hero p { font-size: var(--fs-body); max-width: 44ch; }
  .room-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: var(--sp-6);
    margin-top: var(--sp-4);
  }
  .room-card {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
    transition: background .25s ease, border-color .25s ease, transform .25s ease, box-shadow .25s ease;
  }
  .room-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-border);
    box-shadow:
      0 18px 50px -16px var(--accent-fill),
      0 6px 24px rgba(0, 0, 0, 0.45);
  }
  .room-card:active { transform: translateY(-2px) scale(.995); }
  /* each room is its own "light": an orb that echoes the breathing circle */
  .room-card-art {
    width: 100%;
    height: 150px;
    border-radius: 0;
    background:
      radial-gradient(circle at 50% 52%, transparent 33%, var(--accent-border) 34.5%, transparent 37%),
      radial-gradient(circle at 50% 52%, var(--accent-fill) 0%, transparent 55%),
      radial-gradient(circle at 85% 110%, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 55%),
      color-mix(in srgb, var(--bg-room) 75%, black);
  }
  .room-card:nth-child(2) .room-card-art {
    background:
      radial-gradient(circle at 30% 40%, transparent 24%, var(--accent-border) 25.5%, transparent 28%),
      radial-gradient(circle at 30% 40%, var(--accent-fill) 0%, transparent 45%),
      radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--accent) 20%, transparent) 0%, transparent 50%),
      color-mix(in srgb, var(--bg-room) 75%, black);
  }
  .room-card:nth-child(3) .room-card-art {
    background:
      radial-gradient(circle at 72% 30%, transparent 28%, var(--accent-border) 29.5%, transparent 32%),
      radial-gradient(circle at 72% 30%, var(--accent-fill) 0%, transparent 50%),
      radial-gradient(circle at 0% 100%, color-mix(in srgb, var(--accent) 24%, transparent) 0%, transparent 55%),
      color-mix(in srgb, var(--bg-room) 75%, black);
  }
  .room-card:nth-child(4) .room-card-art {
    background:
      radial-gradient(circle at 48% 88%, transparent 38%, var(--accent-border) 39.5%, transparent 42%),
      radial-gradient(circle at 48% 88%, var(--accent-fill) 0%, transparent 60%),
      radial-gradient(circle at 90% 10%, color-mix(in srgb, var(--accent) 18%, transparent) 0%, transparent 45%),
      color-mix(in srgb, var(--bg-room) 75%, black);
  }
  .room-card-text { padding: 14px 18px 18px; gap: 4px; }
  .room-card-name { font-family: var(--font-display); font-size: 19px; font-weight: 300; }
  .room-card-go { display: none; }

  /* --- Room view: stage left, sticky rail right --- */
  #roomView {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    column-gap: 56px;
    align-items: start;
  }
  .room-head { grid-column: 1 / -1; padding: var(--sp-6) 0 var(--sp-2); }
  .room-title { font-size: 40px; }
  .stage { grid-column: 1; grid-row: 2; min-height: 58vh; }
  .reactions { grid-column: 1; grid-row: 3; }
  .rail {
    grid-column: 2;
    grid-row: 2 / span 2;
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
    position: sticky;
    top: var(--sp-6);
  }
  .rail > details {
    margin-top: 0 !important;     /* override inline mobile margin */
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-card);
    padding: 14px 16px;
  }
  .rail .nowplaying { margin-top: 0; }
  /* the centerpiece breathes bigger on a big screen */
  .breath { transform: scale(1.4); margin: 48px 0; }
  .pomo { transform: scale(1.25); margin: 32px 0 16px; }
  .pomo-tag { font-size: var(--fs-body); }
  #focusPanel .todo { max-width: 420px; }
}

/* 3.10 Now-playing + maker credit strip */
.nowplaying {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-card);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.np-row { display: flex; align-items: center; gap: var(--sp-3); }
.np-art {
  width: 46px; height: 46px;
  border-radius: var(--r-md);
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 30%, #2a2440));
}
.np-meta { min-width: 0; flex: 1; }
.np-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-sub { font-size: var(--fs-micro); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.live { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 500; letter-spacing: .5px; flex-shrink: 0; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
@media (prefers-reduced-motion: no-preference) { .live-dot { animation: livePulse 2s ease-in-out infinite; } }
@keyframes livePulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.np-progress { height: 3px; border-radius: var(--r-pill); background: rgba(255,255,255,.08); overflow: hidden; }
.np-progress > div { height: 100%; width: 0; background: var(--accent); transition: width 1s linear; }
.np-credit {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding-top: var(--sp-1);
}
.np-credit .spark { color: var(--accent); flex-shrink: 0; }
.np-credit-text { flex: 1; min-width: 0; }
.np-credit-top { font-size: var(--fs-micro); color: var(--text-2); }
.np-credit-bottom { font-size: 12px; font-weight: 500; color: var(--text-1); }
.np-cta { flex-shrink: 0; }
