/* room.css — the room: a single, strictly non-scrolling viewport that is the
   café. All colors and fonts come from tokens.css or from live custom
   properties painted by sky.js; logical properties only (check.mjs enforces). */

html,
body {
  block-size: 100%;
  overflow: hidden;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr); /* a 100%-column that content cannot inflate: without it, long footer content grows the track and overflows small screens */
  block-size: 100dvh;
}

/* ---------- chrome (header / footer) ---------- */

.chrome {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  padding-block: var(--space-3);
  padding-inline: var(--space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.brand__logo {
  display: block;
  inline-size: clamp(7rem, 22vw, 13rem);
  aspect-ratio: 3.105;
  background-color: var(--logo-ink);
  -webkit-mask: url('../img/logo-800w.png') center / contain no-repeat;
  mask: url('../img/logo-800w.png') center / contain no-repeat;
}

[data-theme='midnight'] .brand__logo {
  -webkit-mask-image: url('../img/logo-white-800w.png');
  mask-image: url('../img/logo-white-800w.png');
}

.controls {
  display: inline-flex;
  gap: var(--space-2);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  inline-size: var(--target-touch);
  block-size: var(--target-touch);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background-color: color-mix(in srgb, var(--surface) 72%, transparent);
  color: var(--text);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background-color var(--dur-fast) var(--ease-settle);
}

.icon-button:hover {
  background-color: color-mix(in srgb, var(--surface) 90%, transparent);
}

.icon-button[aria-disabled='true'] {
  opacity: 0.5;
}

.icon-button .icon {
  grid-area: 1 / 1;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  transition: opacity var(--dur-fast) var(--ease-settle), transform var(--dur-fast) var(--ease-settle);
}

.icon-button .icon--alt {
  opacity: 0;
  transform: scale(0.55);
}

.icon-button[data-flipped] .icon--base {
  opacity: 0;
  transform: scale(0.55);
}

.icon-button[data-flipped] .icon--alt {
  opacity: 1;
  transform: scale(1);
}

/* ---------- the scene ---------- */

.scene {
  position: relative;
  min-block-size: 0;
  overflow: hidden;
  background-color: var(--forest-deep);
}

/* the slideshow: two stacked slides, crossfaded by gallery.js */
.scene__slides {
  position: absolute;
  inset: 0;
}

.scene__slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-settle);
}

.scene__slide.is-active {
  opacity: 1;
}

.scene__slide img {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  object-position: 50% 32%;
  animation: ken-burns 45s linear infinite alternate;
}

.scene__slide:nth-child(2) img {
  animation-direction: alternate-reverse;
}

.scene__slide:not(.is-active) img {
  animation-play-state: paused;
}

@keyframes ken-burns {
  from {
    transform: scale(1.08) translate3d(-1.5%, -1%, 0);
  }
  to {
    transform: scale(1.16) translate3d(1.5%, 1%, 0);
  }
}

.scene__sky,
.scene__rain,
.scene__mist,
.scene__grain,
.scene__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scene__sky {
  background: linear-gradient(180deg, var(--wash-live, var(--wash-day)) 0%, transparent 78%);
}

.scene[data-sky='golden'] .scene__sky {
  --wash-live: var(--wash-golden);
}

.scene[data-sky='twilight'] .scene__sky {
  --wash-live: var(--wash-twilight);
}

/* weather layers */
.scene__rain {
  inset-block: -60% 0;
  background-image: repeating-linear-gradient(12deg, transparent 0 0.9rem, var(--rain-streak) 0.9rem calc(0.9rem + 1px));
  opacity: 0;
}

.scene[data-weather='drizzle'] .scene__rain {
  opacity: 0.3;
  animation: rain-fall 1.6s linear infinite;
}

.scene[data-weather='rain'] .scene__rain,
.scene[data-weather='thunder'] .scene__rain {
  opacity: 0.5;
  animation: rain-fall 0.8s linear infinite;
}

@keyframes rain-fall {
  to {
    transform: translateY(10%);
  }
}

.scene__mist {
  background: linear-gradient(180deg, transparent 30%, var(--mist-veil) 100%);
  opacity: 0;
}

.scene[data-weather='fog'] .scene__mist {
  opacity: 1;
}

/* film grain — also softens the scene photo at desktop sizes */
.scene__grain {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.35;
  mix-blend-mode: overlay;
}

.scene__vignette {
  background: radial-gradient(120% 90% at 50% 42%, transparent 55%, color-mix(in srgb, var(--forest-deep) 42%, transparent) 100%);
}

/* ---------- floating cards: one base, modifiers per case (radio, weather) ---------- */

.card {
  position: absolute;
  z-index: 25;
  inset-block-start: var(--space-4);
  inline-size: clamp(15rem, 24vw, 21rem); /* both cards share one footprint */
}

.card--radio {
  inset-inline-end: var(--space-4);
}

.card--wx {
  inset-inline-start: var(--space-4);
}

.card__label {
  display: inline-block;
  margin: 0 0 var(--space-1);
  padding-block: var(--space-1);
  padding-inline: var(--space-2);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  background-color: var(--surface); /* solid: translucent over a photo turns murky */
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

/* the radio card carries no chrome of its own: the embed is a rounded object
   floating on the scene, so a card background would peek through its corners
   (Spotify embed stays visible, per their guidelines) */

/* the iFrame API replaces the mount div with the iframe itself */
.card--radio iframe {
  display: block;
  inline-size: 100%;
  block-size: 152px;
  border: 0;
  /* pin the embed's color-scheme: our midnight color-scheme propagates into
     the cross-origin iframe and Spotify then paints white canvas corners */
  color-scheme: light;
}

/* ---------- the weather card (card--wx): a Samsung-weather-style stage that
   acts out the live Mysuru conditions. All state arrives as data attributes
   on .scene (data-sky, data-weather) painted by sky.js — CSS reacts, no JS
   per-element styling. Solid body per the floating-elements rule. ---------- */

.card--wx .wx__body {
  background-color: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}

.wx__stage {
  position: relative;
  block-size: 5.75rem;
  overflow: hidden;
  background: linear-gradient(180deg, var(--wx-day-top), var(--wx-day-bottom));
  transition: background var(--dur-slow) var(--ease-settle);
}

.scene[data-sky='golden'] .wx__stage {
  background: linear-gradient(180deg, var(--wx-golden-top), var(--wx-golden-bottom));
}

.scene[data-sky='twilight'] .wx__stage {
  background: linear-gradient(180deg, var(--wx-twilight-top), var(--wx-twilight-bottom));
}

.scene[data-sky='night'] .wx__stage {
  background: linear-gradient(180deg, var(--wx-night-top), var(--wx-night-bottom));
}

/* stars: a 1px dot plus box-shadow siblings; only up at night */
.wx__stars {
  position: absolute;
  inset-block-start: 14%;
  inset-inline-start: 8%;
  inline-size: 1px;
  block-size: 1px;
  border-radius: 50%;
  background-color: var(--wx-star);
  box-shadow:
    1.4rem 0.6rem 0 0 var(--wx-star), 3.2rem 1.8rem 0 0 var(--wx-star),
    5.6rem 0.4rem 0 0 var(--wx-star), 7.4rem 2.2rem 0 0 var(--wx-star),
    9.2rem 0.9rem 0 0 var(--wx-star), 2.2rem 3rem 0 0 var(--wx-star),
    6.4rem 3.2rem 0 0 var(--wx-star), 10.6rem 2.6rem 0 0 var(--wx-star),
    12.4rem 1.2rem 0 0 var(--wx-star), 4.4rem 2.8rem 0 0 var(--wx-star);
  opacity: 0;
}

.scene[data-sky='night'] .wx__stars {
  opacity: 1;
  animation: wx-twinkle 3.2s ease-in-out infinite;
}

@keyframes wx-twinkle {
  50% {
    opacity: 0.4;
  }
}

/* sun: disc plus a slowly turning ray ring (masked conic gradient) */
.wx__sun {
  position: absolute;
  inset-block-start: 16%;
  inset-inline-start: 14%;
  inline-size: 1.6rem;
  block-size: 1.6rem;
  border-radius: 50%;
  background-color: var(--sun-disc);
  color: var(--sun-disc);
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-settle);
  animation: wx-float 7s ease-in-out infinite;
}

.wx__sun::before {
  content: '';
  position: absolute;
  inset: -0.55rem;
  background: repeating-conic-gradient(from 0deg, currentColor 0deg 5deg, transparent 5deg 45deg);
  -webkit-mask: radial-gradient(closest-side, transparent 58%, black 60%);
  mask: radial-gradient(closest-side, transparent 58%, black 60%);
  animation: wx-spin 26s linear infinite;
}

.scene[data-sky='day'] .wx__sun,
.scene[data-sky='golden'] .wx__sun {
  opacity: 1;
}

@keyframes wx-spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes wx-float {
  50% {
    transform: translateY(-0.2rem);
  }
}

/* moon: same shadow-shift phase disc as the bottom chip; sky.js paints --moon-shift */
.wx__moon {
  position: absolute;
  inset-block-start: 14%;
  inset-inline-end: 16%;
  inline-size: 1.3rem;
  block-size: 1.3rem;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--moon-disc);
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-settle);
  animation: wx-float 8s ease-in-out infinite;
}

.wx__moon span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-color: color-mix(in srgb, var(--moon-shadow) 78%, transparent);
  transform: translateX(var(--moon-shift, -100%));
}

.scene[data-sky='twilight'] .wx__moon,
.scene[data-sky='night'] .wx__moon {
  opacity: 1;
}

/* clouds: a pill with two puff pseudos, drifting across the stage */
.wx__cloud {
  position: absolute;
  inset-inline-start: 0;
  inline-size: 2.8rem;
  block-size: 0.85rem;
  border-radius: 999px;
  background-color: var(--wx-cloud);
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-settle), background-color var(--dur-slow) var(--ease-settle);
}

.wx__cloud::before,
.wx__cloud::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background-color: inherit;
}

.wx__cloud::before {
  inline-size: 1.15rem;
  block-size: 1.15rem;
  inset-inline-start: 0.4rem;
  inset-block-end: 0.2rem;
}

.wx__cloud::after {
  inline-size: 0.85rem;
  block-size: 0.85rem;
  inset-inline-start: 1.45rem;
  inset-block-end: 0.25rem;
}

.wx__cloud--near {
  inset-block-start: 36%;
  animation: wx-drift 34s linear infinite;
}

.wx__cloud--far {
  inset-block-start: 12%;
  inline-size: 2.1rem;
  animation: wx-drift 52s linear infinite;
  animation-delay: -18s;
}

.scene[data-weather='cloud'] .wx__cloud,
.scene[data-weather='drizzle'] .wx__cloud,
.scene[data-weather='rain'] .wx__cloud,
.scene[data-weather='thunder'] .wx__cloud,
.scene[data-weather='fog'] .wx__cloud {
  opacity: 1;
}

.scene[data-sky='twilight'] .wx__cloud,
.scene[data-sky='night'] .wx__cloud {
  background-color: var(--wx-cloud-night);
}

@keyframes wx-drift {
  from {
    transform: translateX(-4.5rem);
  }
  to {
    transform: translateX(26rem);
  }
}

/* rain: the scene's streak layer, miniaturized */
.wx__rain {
  position: absolute;
  inset-block: -45% 0;
  inset-inline: 0;
  background-image: repeating-linear-gradient(12deg, transparent 0 0.7rem, var(--wx-drop) 0.7rem calc(0.7rem + 1px));
  opacity: 0;
}

.scene[data-weather='drizzle'] .wx__rain {
  opacity: 0.45;
  animation: wx-rain 1.4s linear infinite;
}

.scene[data-weather='rain'] .wx__rain,
.scene[data-weather='thunder'] .wx__rain {
  opacity: 0.7;
  animation: wx-rain 0.8s linear infinite;
}

@keyframes wx-rain {
  to {
    transform: translateY(25%);
  }
}

.wx__mist {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 35%, var(--mist-veil) 100%);
  opacity: 0;
  transition: opacity var(--dur-med) var(--ease-settle);
}

.scene[data-weather='fog'] .wx__mist {
  opacity: 1;
}

/* distant lightning for thunderstorms: two quick soft flashes, then a long rest */
.wx__flash {
  position: absolute;
  inset: 0;
  background-color: var(--wx-flash);
  opacity: 0;
}

.scene[data-weather='thunder'] .wx__flash {
  animation: wx-flash 9s linear infinite;
}

@keyframes wx-flash {
  0%, 88%, 92%, 96%, 100% {
    opacity: 0;
  }
  90%, 94% {
    opacity: 0.5;
  }
}

.wx__readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-2) var(--space-3) var(--space-3);
}

.wx__temp {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  line-height: var(--leading-display);
}

.wx__cond {
  font-size: var(--text-xs);
  color: var(--text-dim);
  text-align: end;
}

.sound-hint {
  position: absolute;
  z-index: 26;
  inset-inline-start: 50%;
  inset-block-end: var(--space-6);
  transform: translateX(-50%);
  margin: 0;
  padding-block: var(--space-1);
  padding-inline: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text);
  background-color: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: hint-pulse 2.4s var(--ease-settle) infinite;
}

.sound-hint[hidden] {
  display: none;
}

@keyframes hint-pulse {
  50% {
    opacity: 0.55;
  }
}

/* ---------- bottom bar ---------- */

.hours {
  margin: 0;
  font-size: var(--text-s);
  color: var(--text-dim);
  min-inline-size: 0; /* shrink and wrap instead of running off small screens */
}

.text-link {
  color: var(--text);
  text-decoration-color: var(--accent);
}

.chips {
  display: inline-flex;
  flex-wrap: nowrap; /* one row forever: stacking the chips grows the footer row, shrinks the 1fr scene, and shifts the photo (CLS) */
  gap: var(--space-2);
  min-inline-size: 0; /* let the row shrink so the chips truncate (ellipsis) instead of overflowing the viewport */
  max-inline-size: 100%;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding-block: var(--space-1);
  padding-inline: var(--space-3);
  font-size: var(--text-s);
  color: var(--text);
  background-color: color-mix(in srgb, var(--surface) 72%, transparent);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  /* one line forever: sky.js swaps the chip text after first paint, and a
     wrap would grow the footer row, shrink the 1fr scene, and shift the
     photo (CLS). truncate instead; the card carries the full readout. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-inline-size: 0; /* let the row shrink and truncate instead of stacking */
}

.moon-mini {
  position: relative;
  inline-size: 1rem;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--moon-disc);
}

/* the open/opens-in board chip: café-local clock + live state, painted by
   hours.js; the dot is dim until JS declares the state. `soon` (15 min to
   either flip) starts the pulse — green while open, amber while waiting */
.status-dot {
  flex: none;
  inline-size: 0.5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background-color: var(--text-dim);
}

.chip[data-open='true'] .status-dot {
  background-color: var(--status-open);
  color: var(--status-open);
}

.chip[data-open='false'] .status-dot {
  background-color: var(--accent);
  color: var(--accent);
}

.chip[data-soon='true'] .status-dot {
  animation: status-pulse 2.8s var(--ease-settle) infinite;
}

@keyframes status-pulse {
  50% {
    box-shadow: 0 0 0 0.28rem color-mix(in srgb, currentColor 28%, transparent);
  }
}

.moon-mini span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background-color: color-mix(in srgb, var(--moon-shadow) 45%, transparent);
  transform: translateX(var(--moon-shift, -100%));
}

/* ---------- the Questions modal: reference content over a soft scrim,
   centered; closes on backdrop click or Escape (faq.js). Stateless by
   design — it never persists and never touches the weather card, which
   simply waits behind the scrim. ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40; /* above the chrome (30) and the floating cards */
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background-color: var(--scrim);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.modal[hidden] {
  display: none; /* the author display:grid would otherwise beat the UA [hidden] rule */
}

.modal__panel {
  display: flex;
  flex-direction: column;
  inline-size: min(24rem, 100%);
  max-block-size: min(32rem, 78dvh);
  overflow: hidden;
  background-color: var(--surface); /* solid: floating elements get solid backgrounds */
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding-inline: var(--space-4);
  animation: modal-in 180ms var(--ease-settle);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(0.4rem);
  }
}

.faq__body {
  flex: 1 1 auto;
  min-block-size: 0;
  overflow-y: auto; /* internal scroll: the room itself never scrolls */
  padding-block: var(--space-2);
}

.faq__list {
  margin-block: 0;
}

.faq__list dt {
  font-family: var(--font-display);
  font-size: var(--text-l);
  margin-block-start: var(--space-3);
  color: var(--text);
}

.faq__list dd {
  margin-block: var(--space-1) 0;
  margin-inline: 0;
  padding: 0;
  font-size: var(--text-s);
  color: var(--text-dim);
}

button.text-link {
  padding: 0;
  border: 0;
  background: none;
  text-decoration-line: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.2em;
}

/* ---------- responsive ---------- */

@media (max-width: 40rem) {
  .card {
    inline-size: min(13rem, 62vw);
  }

  /* side by side would collide with the radio at this width: the weather
     card docks above the footer on the start edge instead */
  .card--wx {
    inset-block-start: auto;
    inset-block-end: var(--space-3);
    inline-size: min(11rem, 52vw);
  }

  /* the narrow card reads better stacked: big temp over the condition line */
  .wx__readout {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .wx__cond {
    text-align: start;
  }

  /* …and the first-play hint moves to the free bottom-right corner so it
     never sits on top of the docked weather card */
  .sound-hint {
    inset-inline-start: auto;
    inset-inline-end: var(--space-3);
    transform: none;
  }

  .chrome {
    padding-inline: var(--space-3);
  }
}

@media (max-height: 30rem) {
  .chips,
  .brand__logo,
  .card--wx {
    display: none;
  }

  .card {
    inline-size: 13rem;
  }

  .chrome {
    padding-block: var(--space-2);
  }
}
