/* ==========================================================================
   estimato — room: header, timer pill, Invite, tabs, round bar (§5). Loaded
   after styles.css (tokens, buttons, the room frame of the room-scroll-css
   contract); the menu is in css/overlays.css, the table in css/table.css.
   States from app.js: .room-tab.active[data-tab], #timerDisplay.warning.
   1 Header; 2 Timer and Invite; 3 Tabs; 4 Round bar; 5 Phones; 6 Reduced motion.
   ========================================================================== */

/* 1. Header: one wrapping row — mark, title, code | controls (timer, Invite, menu);
   on phones grid areas lay the same DOM out as two rows, the timer on the second. */
.room-header {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  margin: var(--s-3) var(--s-4) 0;
  padding: var(--s-2) var(--s-3) var(--s-2) var(--s-4);
  border-radius: var(--r-sheet);
  background: var(--sheet);
  box-shadow: var(--lift-1);
}

/* The mark as a mask, so it follows the theme */
.room-mark {
  width: 30px;
  height: 30px;
  flex: none;
  background: var(--cobalt);
  -webkit-mask: url("/static/brand/mark-v2.svg") center / contain no-repeat;
  mask: url("/static/brand/mark-v2.svg") center / contain no-repeat;
}

.room-title {
  min-width: 0;
  font-size: var(--fs-3);
  line-height: 1.2;
}

.room-code {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 32px;
  padding: 0 var(--s-3);
  border-radius: var(--r-pill);
  background: var(--tint);
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.room-code-value {
  font-size: var(--fs-2);
  font-weight: 800;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Controls wrap as one unit and stay at the right edge (the menu drops from it) */
.room-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1);
  margin-left: auto;
}

/* 2. Timer pill → countdown in Numerals; red in the last 30 s, no blinking */
.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  min-height: 44px;
  padding: 0 var(--s-1) 0 var(--s-3);
  border-radius: var(--r-pill);
  background: var(--tint);
}

.timer-pill > .icon {
  color: var(--cobalt);
}

.timer-minutes {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-2);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  appearance: textfield;
}

.timer-minutes::-webkit-outer-spin-button,
.timer-minutes::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.timer-unit {
  font-size: var(--fs-1);
  font-weight: 600;
  color: var(--muted);
}

.timer-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s-3);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--cobalt);
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out);
}

.timer-btn:hover:not(:disabled) {
  background: var(--sheet);
}

.timer-btn:disabled {
  opacity: 0.5;
}

.timer-display {
  min-width: 4.5ch;
  font-family: var(--font-numerals);
  font-size: 1.0625rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--ink);
}

.timer-display.warning {
  color: var(--marker-red);
}

/* Invite: ghost button; icon-only on phones */
.invite-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-3);
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}

.invite-btn:hover {
  background: var(--tint);
  color: var(--cobalt);
}

/* 3. Tabs: segmented control of toggle buttons (aria-pressed) */
.room-tabs {
  flex: none;
  align-self: flex-start;
  display: inline-flex;
  gap: var(--s-1);
  margin: 0 var(--s-4);
  padding: var(--s-1);
  border-radius: 12px;
  background: var(--sheet);
  box-shadow: var(--lift-1);
}

.room-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-4);
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}

.room-tab:hover {
  color: var(--cobalt);
}

.room-tab.active {
  background: var(--tint);
  color: var(--cobalt);
  font-weight: 700;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--tint);
  color: var(--cobalt);
  font-size: var(--fs-1);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* 4. Round bar: status and progress, then the main action */
.round-bar {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3) var(--s-4);
}

.voting-status {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-width: 0;
}

.status-text {
  font-size: var(--fs-3);
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

.progress-bar {
  width: 200px;
  max-width: 100%;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--rule);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--cobalt);
  transition: width var(--t-base) var(--ease-out);
}

.round-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* 5. Phones: the same DOM as two rows, the timer alone on the second --------- */
@media (max-width: 640px) {
  .room-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "mark title invite menu"
      "mark code invite menu"
      "timer timer timer timer";
    gap: 0 var(--s-2);
    margin: 0;
    padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
    border-radius: 0;
  }

  .room-mark {
    grid-area: mark;
  }

  .room-title {
    grid-area: title;
    font-size: var(--fs-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .room-controls {
    display: contents;
  }

  .room-code {
    grid-area: code;
    min-height: 0;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
  }

  .timer-pill {
    grid-area: timer;
    justify-content: center;
    margin-top: var(--s-2);
  }

  .invite-btn {
    grid-area: invite;
    width: 44px;
    padding: 0;
    background: var(--tint);
    color: var(--cobalt);
  }

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

  .room-menu {
    grid-area: menu;
  }

  .room-tabs {
    align-self: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-text {
    font-size: var(--fs-2);
  }

  .round-actions {
    width: 100%;
  }

  .round-actions .btn {
    flex: 1 1 auto;
  }
}

/* 6. Reduced motion (§6): no animation above; every transition takes --t-fast /
   --t-base, which styles.css collapses to 0 ms. */
@media (prefers-reduced-motion: reduce) {
  .room-tab,
  .timer-btn,
  .invite-btn,
  .progress-fill {
    transition: none;
  }
}
