/* ==========================================================================
   How are we feeling? — Frutiger Aero glass over a time-of-day sky
   Theme is chosen by <html data-time="morning|day|evening|night"> (script.js)
   ========================================================================== */

/* ---------- Theme tokens ---------- */

:root {
  /* day is the default / no-JS fallback */
  --ink: #0a3d62;
  --ink-glow: 0 1px 0 rgba(255, 255, 255, 0.7), 0 0 22px rgba(255, 255, 255, 0.65);

  --glass-top: rgba(255, 255, 255, 0.72);
  --glass-bottom: rgba(255, 255, 255, 0.3);
  --glass-border: rgba(255, 255, 255, 0.85);
  --glass-shadow: rgba(8, 60, 120, 0.3);
  --glass-fallback: rgba(255, 255, 255, 0.55);

  --tile-top: rgba(255, 255, 255, 0.7);
  --tile-bottom: rgba(255, 255, 255, 0.22);

  --cloud: #ffffff;
  --cloud-opacity: 0.95;

  --orb-color: #fff7b8;
  --orb-x: 80%;
  --orb-y: 15%;
  --orb-glow: 0 0 50px 22px rgba(255, 248, 190, 0.75), 0 0 160px 80px rgba(255, 255, 255, 0.35);
  --moon: 0;

  --stars: 0;
  --horizon: rgba(255, 255, 255, 0.55);

  --fade: 2.5s ease;
}

:root[data-time="morning"] {
  --ink: #17406a;
  --ink-glow: 0 1px 0 rgba(255, 255, 255, 0.7), 0 0 22px rgba(255, 244, 230, 0.7);
  --glass-shadow: rgba(120, 80, 90, 0.28);
  --cloud: #fff1ea;
  --cloud-opacity: 0.92;
  --orb-color: #ffe9a8;
  --orb-x: 16%;
  --orb-y: 66%;
  --orb-glow: 0 0 60px 26px rgba(255, 220, 150, 0.8), 0 0 180px 90px rgba(255, 200, 150, 0.4);
  --horizon: rgba(255, 226, 200, 0.6);
}

:root[data-time="evening"] {
  --ink: #2b1846;
  --ink-glow: 0 1px 0 rgba(255, 255, 255, 0.55), 0 0 22px rgba(255, 225, 190, 0.6);
  --glass-top: rgba(255, 250, 245, 0.7);
  --glass-bottom: rgba(255, 240, 230, 0.34);
  --glass-shadow: rgba(50, 20, 70, 0.38);
  --glass-fallback: rgba(255, 244, 236, 0.6);
  --cloud: #ffc9a6;
  --cloud-opacity: 0.85;
  --orb-color: #ffb648;
  --orb-x: 82%;
  --orb-y: 72%;
  --orb-glow: 0 0 60px 28px rgba(255, 170, 70, 0.8), 0 0 200px 100px rgba(255, 140, 80, 0.4);
  --horizon: rgba(255, 214, 140, 0.55);
}

:root[data-time="night"] {
  --ink: #eef6ff;
  --ink-glow: 0 1px 2px rgba(0, 10, 40, 0.6), 0 0 22px rgba(150, 190, 255, 0.55);
  --glass-top: rgba(150, 180, 255, 0.26);
  --glass-bottom: rgba(16, 30, 84, 0.42);
  --glass-border: rgba(190, 215, 255, 0.5);
  --glass-shadow: rgba(0, 4, 24, 0.6);
  --glass-fallback: rgba(16, 30, 84, 0.72);
  --tile-top: rgba(170, 200, 255, 0.28);
  --tile-bottom: rgba(40, 60, 130, 0.22);
  --cloud: #8090c0;
  --cloud-opacity: 0.32;
  --orb-color: #eef3ff;
  --orb-x: 78%;
  --orb-y: 17%;
  --orb-glow: 0 0 40px 14px rgba(200, 220, 255, 0.5), 0 0 140px 70px rgba(120, 160, 255, 0.22);
  --moon: 1;
  --stars: 1;
  --horizon: rgba(90, 130, 220, 0.3);
}

/* ---------- Base ---------- */

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

html {
  background: #3fa9f0;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  position: relative;
  z-index: 0;
  color: var(--ink);
  font-family: "Segoe UI", "Frutiger", "Frutiger Linotype", "Helvetica Neue", system-ui, sans-serif;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  transition: color var(--fade);
}

/* ---------- Sky ---------- */

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

/* Gradients can't be transitioned, so each sky is its own layer and they cross-fade. */
.sky__layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--fade);
}

.sky__layer--morning {
  background: linear-gradient(to bottom, #7fb8e8 0%, #bfe0f5 45%, #ffe2c2 78%, #ffc9a0 100%);
}

.sky__layer--day {
  background: linear-gradient(to bottom, #1a7fd6 0%, #3fa9f0 40%, #8fdcf7 75%, #c9f5e3 100%);
}

.sky__layer--evening {
  background: linear-gradient(to bottom, #3b3a7a 0%, #8a4f9e 35%, #f08a5d 70%, #ffd27a 100%);
}

.sky__layer--night {
  background: linear-gradient(to bottom, #050b24 0%, #0d1b4a 50%, #1c2f6b 85%, #2a4380 100%);
}

[data-time="morning"] .sky__layer--morning,
[data-time="day"] .sky__layer--day,
[data-time="evening"] .sky__layer--evening,
[data-time="night"] .sky__layer--night {
  opacity: 1;
}

/* Stars */

.stars {
  position: absolute;
  inset: 0;
  opacity: var(--stars);
  transition: opacity var(--fade);
  -webkit-mask-image: linear-gradient(to bottom, #000 35%, transparent 90%);
  mask-image: linear-gradient(to bottom, #000 35%, transparent 90%);
}

.stars::before,
.stars::after {
  content: "";
  position: absolute;
  inset: 0;
  animation: twinkle 5s ease-in-out infinite alternate;
}

.stars::before {
  background-image:
    radial-gradient(1.6px 1.6px at 24px 36px, #fff, transparent),
    radial-gradient(1.2px 1.2px at 96px 142px, #fff, transparent),
    radial-gradient(1.8px 1.8px at 171px 64px, #dfeaff, transparent),
    radial-gradient(1.1px 1.1px at 210px 190px, #fff, transparent),
    radial-gradient(1.3px 1.3px at 58px 208px, #fff, transparent);
  background-size: 233px 233px;
}

.stars::after {
  background-image:
    radial-gradient(1.4px 1.4px at 40px 120px, #fff, transparent),
    radial-gradient(2px 2px at 150px 30px, #fff, transparent),
    radial-gradient(1.1px 1.1px at 260px 210px, #cfe0ff, transparent),
    radial-gradient(1.5px 1.5px at 300px 90px, #fff, transparent),
    radial-gradient(1.2px 1.2px at 110px 280px, #fff, transparent);
  background-size: 337px 337px;
  animation-duration: 7s;
  animation-delay: -3s;
}

@keyframes twinkle {
  from { opacity: 0.45; }
  to   { opacity: 1; }
}

/* Sun / moon */

.orb {
  position: absolute;
  left: var(--orb-x);
  top: var(--orb-y);
  width: clamp(84px, 13vw, 150px);
  aspect-ratio: 1;
  border-radius: 50%;
  translate: -50% -50%;
  background-color: var(--orb-color);
  background-image: radial-gradient(circle at 38% 34%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 62%);
  box-shadow: var(--orb-glow);
  transition: left var(--fade), top var(--fade), background-color var(--fade), box-shadow var(--fade);
}

/* Moon craters, only at night */
.orb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: var(--moon);
  transition: opacity var(--fade);
  background-image:
    radial-gradient(circle at 62% 30%, rgba(120, 140, 190, 0.38) 0 9%, transparent 10%),
    radial-gradient(circle at 34% 58%, rgba(120, 140, 190, 0.32) 0 13%, transparent 14%),
    radial-gradient(circle at 68% 68%, rgba(120, 140, 190, 0.28) 0 7%, transparent 8%),
    radial-gradient(circle at 44% 24%, rgba(120, 140, 190, 0.22) 0 5%, transparent 6%);
}

/* Clouds: a flat colour (so it can transition) cut into a cloud shape by a mask */

.cloud {
  --w: 340px;
  position: absolute;
  left: 0;
  top: var(--y);
  width: var(--w);
  height: calc(var(--w) * 0.4);
  opacity: var(--cloud-opacity);
  background-color: var(--cloud);
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0) 45%, rgba(40, 80, 140, 0.16));
  -webkit-mask-image:
    radial-gradient(ellipse 30% 44% at 30% 60%, #000 55%, transparent 100%),
    radial-gradient(ellipse 25% 48% at 50% 42%, #000 55%, transparent 100%),
    radial-gradient(ellipse 27% 40% at 70% 62%, #000 55%, transparent 100%),
    radial-gradient(ellipse 46% 26% at 50% 74%, #000 55%, transparent 100%);
  mask-image:
    radial-gradient(ellipse 30% 44% at 30% 60%, #000 55%, transparent 100%),
    radial-gradient(ellipse 25% 48% at 50% 42%, #000 55%, transparent 100%),
    radial-gradient(ellipse 27% 40% at 70% 62%, #000 55%, transparent 100%),
    radial-gradient(ellipse 46% 26% at 50% 74%, #000 55%, transparent 100%);
  filter: blur(3px);
  transition: background-color var(--fade), opacity var(--fade);
  animation: drift var(--dur) linear infinite;
  animation-delay: var(--delay);
  will-change: transform;
}

/* Negative delays start each cloud part-way across, so the sky is never empty. */
.cloud--1 { --w: clamp(220px, 30vw, 420px); --y: 6%;  --dur: 110s; --delay: -20s; }
.cloud--2 { --w: clamp(160px, 20vw, 280px); --y: 22%; --dur: 150s; --delay: -95s; }
.cloud--3 { --w: clamp(260px, 36vw, 520px); --y: 38%; --dur: 95s;  --delay: -60s; }
.cloud--4 { --w: clamp(180px, 24vw, 340px); --y: 58%; --dur: 130s; --delay: -40s; }
.cloud--5 { --w: clamp(240px, 32vw, 460px); --y: 72%; --dur: 105s; --delay: -85s; }
.cloud--6 { --w: clamp(140px, 18vw, 240px); --y: 12%; --dur: 170s; --delay: -140s; }

@keyframes drift {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100vw); }
}

/* Soft light along the horizon */
.horizon {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -30vh;
  height: 60vh;
  border-radius: 50%;
  background-color: var(--horizon);
  filter: blur(60px);
  transition: background-color var(--fade);
}

/* ---------- Glass panel ---------- */

.panel {
  position: relative;
  width: min(100%, 700px);
  padding: clamp(1.75rem, 5vw, 3rem) clamp(1.1rem, 4vw, 2.75rem);
  text-align: center;
  border-radius: 28px;
  border: 1px solid var(--glass-border);
  background-image: linear-gradient(to bottom, var(--glass-top), var(--glass-bottom));
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    inset 0 -12px 28px rgba(255, 255, 255, 0.1),
    0 22px 50px -14px var(--glass-shadow);
  overflow: hidden;
}

/* Specular highlight across the top of the glass */
.panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 46%;
  border-radius: 28px 28px 50% 50% / 28px 28px 22% 22%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.04));
  pointer-events: none;
}

[data-time="night"] .panel::before {
  background: linear-gradient(to bottom, rgba(200, 220, 255, 0.16), rgba(200, 220, 255, 0.01));
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel {
    background-color: var(--glass-fallback);
  }
}

.panel > * {
  position: relative; /* above the highlight */
}

h1 {
  margin: 0 0 clamp(1.25rem, 4vw, 2.25rem);
  font-size: clamp(2rem, 7vw, 3.5rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-wrap: balance;
  text-shadow: var(--ink-glow);
}

/* ---------- Feeling buttons ---------- */

.feelings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.6rem, 2vw, 1rem);
}

.feeling {
  display: grid;
  justify-items: center;
  gap: 0.65rem;
  padding: 1.1rem 0.5rem 0.9rem;
  font: inherit;
  color: inherit;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background-image: linear-gradient(to bottom, var(--tile-top), var(--tile-bottom));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 6px 16px -6px var(--glass-shadow);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.feeling--happy  { --hue: #ffc61a; --face-ink: #5a3a00; }
.feeling--sad    { --hue: #3b9cf0; --face-ink: #062a52; }
.feeling--afraid { --hue: #a57bf5; --face-ink: #2a1160; }
.feeling--angry  { --hue: #f24f43; --face-ink: #4d0703; }

/* Glossy orb */
.feeling__face {
  position: relative;
  display: block;
  width: clamp(52px, 11vw, 72px);
  aspect-ratio: 1;
  border-radius: 50%;
  color: var(--face-ink);
  background-color: var(--hue);
  background-image:
    radial-gradient(circle at 50% 108%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%),
    radial-gradient(circle at 50% 42%, rgba(0, 0, 0, 0) 52%, rgba(0, 0, 0, 0.26) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    0 5px 12px -3px rgba(0, 30, 70, 0.45);
}

.feeling__face svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Gloss sits over the face, like a reflection on the orb */
.feeling__face::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  top: 5%;
  height: 34%;
  border-radius: 50%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.04));
  pointer-events: none;
}

.feeling__label {
  font-size: clamp(0.95rem, 2.6vw, 1.1rem);
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Interactive states — apply as soon as `disabled` is removed */
.feeling:not(:disabled):hover {
  transform: translateY(-3px);
  filter: brightness(1.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 12px 22px -8px var(--glass-shadow);
}

.feeling:not(:disabled):active {
  transform: translateY(0) scale(0.98);
  filter: brightness(0.97);
}

.feeling:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

/* Disabled for now: still clearly visible, just calmer and not clickable */
.feeling:disabled {
  cursor: not-allowed;
}

.feeling:disabled .feeling__face {
  filter: saturate(0.78);
}

/* ---------- Small screens ---------- */

@media (max-width: 520px) {
  .feelings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  :root {
    --fade: 0s;
  }

  /* Paused with their negative delays, clouds hold a spread-out position. */
  .cloud {
    animation-play-state: paused;
  }

  .stars::before,
  .stars::after {
    animation: none;
  }

  .feeling {
    transition: none;
  }
}
