/* ============================================================================
   CELESTIAL UI — COMPONENTS
   Every rule uses tokens from tokens.css, so each component follows the
   theme automatically. See STYLE_GUIDE.md for usage + markup.
   ============================================================================ */

/* ── App shell ─────────────────────────────────────────────────────────────
   Desktop (≥768px): fixed left sidebar + content to its right.
   Mobile  (<768px): bottom tab bar; content clears it with bottom padding. */

.main {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding-top: env(safe-area-inset-top, 0px);
}
@media (min-width: 768px) {
  .main { padding-left: var(--sidebar-width); padding-top: 0; }
}

.page {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 2rem 1.25rem calc(3rem + var(--tab-bar-height));
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  animation: fadeUp 0.5s var(--ease-out) both;
}
@media (min-width: 768px) {
  .page { padding-bottom: 4rem; }
}

/* ── Sidebar (desktop) ───────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: none;
  flex-direction: column;
  padding: var(--space-lg) var(--space-md);
  background: var(--color-nav-bg);
  border-right: 1px solid var(--color-divider);
  overflow-y: auto;
  scrollbar-width: thin;                       /* only shows on short windows */
  scrollbar-color: var(--color-divider) transparent;
  z-index: 50;
}
@media (min-width: 768px) {
  .sidebar { display: flex; }
}

/* Brand block: logo stacked above the wordmark, centred. */
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: var(--space-sm) var(--space-sm) var(--space-lg);
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-nav-fg);
}
.brand__logo {
  --icon-size: 56px;
  color: var(--color-tier);
}
.brand__accent { color: var(--color-tier); }   /* second word of the name */

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav__link {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 44px;                     /* touch target */
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--color-nav-fg);
  font-size: 0.95rem;
  font-weight: 600;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
  --icon-size: 30px;
}
.nav__link:hover {
  background: var(--color-nav-hover);
  color: var(--color-text);
}
.nav__link[aria-current="page"] {
  background: var(--color-active-bg);
  color: var(--color-active-fg);
}

.sidebar__footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-divider);
}
.you {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-md);
}
.you:hover { background: var(--color-nav-hover); }
.avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: 0.9rem;
  font-weight: 700;
}
.you__meta { display: flex; flex-direction: column; min-width: 0; }
.you__name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-nav-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.you__tier { font-size: 0.75rem; font-weight: 600; color: var(--color-tier); }
.sidebar__back {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  color: var(--color-nav-link);
}
.sidebar__back:hover { color: var(--color-accent); }

/* ── Tab bar (mobile) ────────────────────────────────────────────────────── */

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  height: calc(var(--tab-bar-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  background: var(--color-nav-bg);
  border-top: 1px solid var(--color-divider);
  z-index: 50;
}
@media (min-width: 768px) {
  .tabbar { display: none; }
}
.tabbar__tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding-top: 8px;
  color: var(--color-nav-fg);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color var(--duration-fast) var(--ease-out);
  --icon-size: 36px;
}
.tabbar__tab[aria-current="page"] { color: var(--color-active-fg); }

/* ── Mask icon ──────────────────────────────────────────────────────────────
   Renders a black-on-transparent SVG in the CURRENT TEXT COLOUR, so icons
   follow the theme and the active-nav colour. Size via --icon-size.
   <span class="icon" style="--icon-src:url(/icons/home.svg)"></span>       */
.icon {
  display: inline-block;
  flex: 0 0 auto;
  width: var(--icon-size, 20px);
  height: var(--icon-size, 20px);
  background-color: currentColor;
  -webkit-mask: var(--icon-src) center / contain no-repeat;
          mask: var(--icon-src) center / contain no-repeat;
}

/* ── Page header + section title ─────────────────────────────────────────── */

.page-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.5rem;
}
.page-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text);
  text-wrap: balance;
}
.page-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.section { display: flex; flex-direction: column; gap: 0.875rem; }
.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.stack { display: flex; flex-direction: column; gap: 1rem; }

/* ── Cards ──────────────────────────────────────────────────────────────────
   .card            default box (periwinkle in light / navy in dark)
   .card--highlight the signature purple card — ONE featured item per view */

.card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.375rem 1.375rem 1.25rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  transition: background var(--duration-fast) ease, border-color var(--duration-fast) ease;
}
a.card:hover { background: var(--color-bg-card-hover); }

.card--highlight {
  background: var(--color-highlight-bg);
  border-color: var(--color-highlight-line);
}
a.card--highlight:hover { background: var(--color-highlight-bg); }

.card__top {                      /* eyebrow left, pill right, top-aligned */
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.card__eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text);
}
.card__top .pill { margin-left: auto; }
.card__title {                    /* big uppercase name — the card's headline */
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.15;
  text-transform: uppercase;
  color: var(--color-text);
}
.card__tagline {
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--color-text-muted);
}
.card__body {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--color-text-muted);
}
.card--highlight .card__body,
.card--highlight .card__tagline { color: var(--color-text); }
.card__footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--color-divider);
}
.card__meta { display: flex; flex-wrap: wrap; gap: 0.4rem; }

@media (max-width: 480px) {
  .card { padding: 1rem; }
  .card__title { font-size: 1.3rem; }
}

/* ── Pills / chips ──────────────────────────────────────────────────────────
   Sits on the page's deep surface so it reads on any card colour. */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--color-text);
  background: var(--color-bg-deep);
  border: 1px solid var(--color-highlight-line);
  border-radius: var(--radius-pill);
}
.pill--sm { padding: 0.2rem 0.625rem; font-size: 0.6875rem; font-weight: 500; }
.pill--gold    { color: var(--color-gold);    background: var(--color-gold-bg); border-color: var(--color-gold-border); }
.pill--success { color: var(--color-success); background: transparent;          border-color: var(--color-success); }
.pill--error   { color: var(--color-error);   background: transparent;          border-color: var(--color-error); }

/* ── Buttons ────────────────────────────────────────────────────────────────
   .btn          PRIMARY — outlined accent, uppercase; fills on hover
   .btn--solid   emphasised primary (use sparingly)
   .btn--quiet   secondary / disabled-looking (e.g. "Available tomorrow")
   .btn--block   full width (forms, mobile CTAs)                            */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.7rem 1.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  background: transparent;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-btn);
  transition: background var(--duration-fast) ease, color var(--duration-fast) ease;
}
.btn:not(:disabled):hover {
  background: var(--color-accent);
  color: var(--color-on-accent);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--solid { background: var(--color-accent); color: var(--color-on-accent); }
.btn--solid:not(:disabled):hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn--quiet {
  color: var(--color-text);
  background: var(--color-bg-deep);
  border-color: var(--color-highlight-line);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  text-transform: none;
}
.btn--quiet:not(:disabled):hover { background: var(--color-bg-deep); color: var(--color-text); border-color: var(--color-border-hover); }
.btn--block { width: 100%; }
.btn__arrow { font-size: 1rem; line-height: 1; }

/* ── Forms ──────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 0.5rem; }
.field__label {
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.field__hint { font-size: 0.75rem; color: var(--color-text-dim); }
.input,
.textarea,
.select {
  width: 100%;
  padding: 0.85rem 1.1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg-deep);
  border: 1px solid var(--color-border-hover);
  border-radius: var(--radius-btn);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.textarea { min-height: 120px; resize: vertical; }
.input::placeholder,
.textarea::placeholder { color: var(--color-text-dim); }
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}
.char-count {
  align-self: flex-end;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Switch row: label + hint on the left, toggle on the right. */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.switch-row__text { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.switch-row__label { font-size: 0.9rem; color: var(--color-text); }
.switch-row__hint  { font-size: 0.75rem; line-height: 1.45; color: var(--color-text-muted); }
.switch {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 26px;
  padding: 0;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-hover);
  background: var(--color-bg-deep);
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.switch::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-text-dim);
  transform: translateY(-50%);
  transition: transform var(--duration-fast) var(--ease-out), background var(--duration-fast);
}
.switch[aria-checked="true"] { background: var(--color-accent-glow); border-color: var(--color-accent); }
.switch[aria-checked="true"]::after { transform: translate(20px, -50%); background: var(--color-accent); }

/* Segmented control (used for Light / Dark / System). */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--color-bg-deep);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.segmented__option {
  min-height: 36px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius-md) - 3px);
  transition: background var(--duration-fast), color var(--duration-fast);
}
.segmented__option:hover { color: var(--color-text); }
.segmented__option[aria-pressed="true"] {
  background: var(--color-active-bg);
  color: var(--color-active-fg);
}

/* ── List rows (history, settings) ───────────────────────────────────────── */

.list {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.list__row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 1.1rem;
  border-top: 1px solid var(--color-divider);
  --icon-size: 22px;
}
.list__row:first-child { border-top: 0; }
a.list__row:hover { background: var(--color-bg-card-hover); }
.list__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list__title { font-size: 0.95rem; font-weight: 600; color: var(--color-text); }
.list__meta  { font-size: 0.8rem; color: var(--color-text-muted); }
.list__aside { font-size: 0.8rem; color: var(--color-text-dim); font-variant-numeric: tabular-nums; }

/* ── Progress bar ───────────────────────────────────────────────────────── */

.progress {
  height: 3px;
  border-radius: 2px;
  background: var(--color-divider);
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  width: var(--value, 0%);
  background: var(--color-accent);
  border-radius: inherit;
  transition: width 0.6s var(--ease-out);
}
.progress-label { font-size: 0.75rem; color: var(--color-text); }

/* ── Empty state ────────────────────────────────────────────────────────── */

.empty {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-card);
}
.empty__mark { font-size: 1.5rem; color: var(--color-accent-light); }

/* ── Bare frame (login) — Luma Weather Machine ──────────────────────────────
   Same column + tokens as .page, without the shell: vertically centred, no
   tab-bar clearance (there is no tab bar here). */
.page--bare {
  min-height: 100dvh;
  justify-content: center;
  padding-bottom: 3rem;
}
.login {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
}
.login__logo {
  --icon-size: 7.5rem;
  color: var(--color-tier);
}
.login__wordmark {
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text);
}
.login__wordmark .brand__accent { color: var(--color-tier); }
.login .card { width: 100%; text-align: left; }
.login__error {
  color: var(--color-error);
  font-size: 0.85rem;
}

/* Inline notice after an action (e.g. "Sent — your machine will speak…"). */
.notice {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.notice--success { color: var(--color-success); }
.notice--error   { color: var(--color-error); }

/* ── Home: current weather (inside the highlight card) ─────────────────────── */
.wx-now { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.25rem 0.9rem; }
.wx-now__temp {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 300;
  line-height: 1;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.wx-now__cond {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-text);
}
.wx-lines {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  list-style: none;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--color-text);
}
.wx-alert { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 0.5rem; }
.wx-alert__text { font-size: 0.85rem; line-height: 1.5; color: var(--color-text); }

/* ── Home: speak buttons ───────────────────────────────────────────────────── */
.speak { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.speak form { display: flex; }
.speak__btn {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-height: 4rem;
  text-align: left;
}
.speak__label { font-weight: 600; }
.speak__hint { font-size: 0.75rem; font-weight: 400; color: var(--color-text-muted); }
.speak__hint { text-transform: none; letter-spacing: 0; }
.speak__label, .speak__hint { white-space: normal; }
@media (max-width: 560px) {
  .speak { grid-template-columns: 1fr; gap: 0.6rem; }
  .speak__btn {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 3.25rem;
  }
  .speak__label { white-space: nowrap; flex-shrink: 0; }
  .speak__hint { text-align: right; }
}

/* ── Device switcher + settings rows ───────────────────────────────────────── */
.switcher { display: flex; flex-direction: column; gap: 0.5rem; }
.switcher__row { display: flex; gap: 0.75rem; }
.switcher__row .select { flex: 1; min-width: 0; }
.loc-own { display: flex; flex-direction: column; gap: 0.75rem; align-items: flex-start; }
.loc-own__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; width: 100%; }
[data-loc][hidden] { display: none; }
.handle-row { display: flex; align-items: center; gap: 0.5rem; }
.handle-row__host { font-size: 0.9rem; color: var(--color-text-muted); white-space: nowrap; }
.handle-row .input { flex: 1; min-width: 0; }
.card__footer .field__hint { margin-right: auto; }
@media (max-width: 480px) {
  .card__footer { flex-wrap: wrap; }
  .handle-row { flex-direction: column; align-items: stretch; }
}

/* ── Phase K: briefing content, switches, schedule slots ───────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.link { color: var(--color-accent-light); text-decoration: underline; text-underline-offset: 2px; }
.card--highlight .link { color: var(--color-text); }

.briefing-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-divider);
}
.choice-group { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; border: 0; padding: 0; margin: 0; }
.choice-group legend { width: 100%; margin-bottom: 0.5rem; padding: 0; }
.choice {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.25rem;
  font-size: 0.9rem;
  color: var(--color-text);
  cursor: pointer;
}
.choice input { width: 1.1rem; height: 1.1rem; accent-color: var(--color-accent); cursor: pointer; }

/* Checkbox rendered as the starter's switch (forms post a real value). */
.switch-input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 26px;
  margin: 0;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-hover);
  background: var(--color-bg-deep);
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.switch-input::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-text-dim);
  transform: translateY(-50%);
  transition: transform var(--duration-fast) var(--ease-out), background var(--duration-fast);
}
.switch-input:checked { background: var(--color-accent-glow); border-color: var(--color-accent); }
.switch-input:checked::after { transform: translate(20px, -50%); background: var(--color-accent); }
.switch-input:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--color-accent-glow); }
.card .switch-row + .switch-row { padding-top: 1rem; border-top: 1px solid var(--color-divider); }

.slots { display: flex; flex-direction: column; gap: 0.6rem; }
.slot { display: flex; align-items: center; gap: 0.75rem; }
.slot__time { flex: 1; min-width: 0; max-width: 12rem; }
.slot .switch-input { margin-left: auto; }
.slot--add { padding-top: 0.75rem; border-top: 1px solid var(--color-divider); }
.slot--add .btn { margin-left: auto; }
.slot__save[hidden] { display: none; }
@media (max-width: 480px) {
  .slot { gap: 0.5rem; flex-wrap: wrap; }
  .slot .btn { padding-left: 0.75rem; padding-right: 0.75rem; }
  .slot__time { min-width: 8.5rem; }
  .slot__save { order: 5; flex: 1 1 100%; }
  .slot--add { flex-wrap: wrap; }
  .slot--add .slot__time { flex: 1 1 100%; max-width: none; }
  .slot--add .btn { flex: 1 1 100%; margin-left: 0; }
}

/* Compact select on the right of a switch-row (Settings → Sounds → Volume). */
.select--compact { width: auto; flex-shrink: 0; min-width: 6.5rem; padding: 0.5rem 0.9rem; }
.card .switch-row + .switch-row { margin-top: 1rem; }

/* iOS Safari centres the value of a time input and sizes it oddly — keep it
   left-aligned and readable like the other inputs. */
.slot__time::-webkit-date-and-time-value { text-align: left; }
.slot__time { -webkit-appearance: none; appearance: none; min-height: 2.9rem; }
