/* ===== Halcyon Sleep — Build-a-Mattress =====
   Rebuilt in plain HTML/CSS/JS from a Storyline original.
   Palette pulls from the portfolio's Magical Forest system. */

:root {
  --cream:        #FBF5EC;
  --cream-50:     #F5ECDC;
  --paper:        #F8EFE0;
  --cocoa:        #553824;
  --cocoa-70:     rgba(85, 56, 36, 0.72);
  --cocoa-45:     rgba(85, 56, 36, 0.45);
  --espresso:     #3D2615;

  --terracotta:   #A9522F;
  --terracotta-600: #8A4124;
  --avocado:      #6F8B3C;
  --avocado-600:  #55701E;
  --mustard:      #D9A441;
  --mustard-600:  #B78422;

  --surface:      #FFFDF7;
  --surface-ring: rgba(85, 56, 36, 0.12);

  --accent-gel:   #E69A5F;   /* top comfort layer */
  --accent-memo:  #BB7B4E;   /* transition */
  --accent-core:  #7A4E30;   /* support core */
  --accent-base:  #4E2F1A;   /* base */

  --radius-md:    14px;
  --radius-lg:    20px;
  --radius-xl:    28px;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;

  --ease:         cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(217,164,65,0.25), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, rgba(169,82,47,0.18), transparent 60%),
    var(--paper);
  color: var(--cocoa);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.55;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(14px, 2vw, 22px);
  gap: clamp(12px, 1.8vw, 18px);
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand__mark {
  width: 44px; height: 44px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 30% 30%, #F6C877 0 22%, transparent 22%),
    linear-gradient(135deg, var(--terracotta), var(--mustard) 70%);
  box-shadow: 0 4px 0 rgba(85, 56, 36, 0.12), inset 0 -2px 0 rgba(255,255,255,0.35);
}
.brand__kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cocoa-45);
}
.brand__title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(18px, 2.2vw, 22px);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.step-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--surface-ring);
  border-radius: 999px;
}
.step-indicator .dot {
  width: 9px; height: 9px;
  border-radius: 999px;
  background: rgba(85,56,36,0.18);
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.step-indicator .dot.is-active {
  background: var(--terracotta);
  transform: scale(1.25);
}
.step-indicator .dot.is-done {
  background: var(--avocado);
}

/* ===== Stage ===== */
.stage {
  min-height: 0;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: clamp(14px, 2vw, 22px);
}
@media (max-width: 820px) {
  .stage { grid-template-columns: 1fr; }
}

/* Canvas column */
.canvas-col {
  background: var(--surface);
  border: 1px solid var(--surface-ring);
  border-radius: var(--radius-xl);
  padding: clamp(18px, 2vw, 26px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  position: relative;
  overflow: hidden;
}
.canvas-col::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(400px 200px at 50% 110%, rgba(217,164,65,0.18), transparent 70%);
  pointer-events: none;
}

.canvas-label {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 16px;
  color: var(--cocoa-70);
  text-align: center;
}

.mattress {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 5 / 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.mattress__frame {
  position: absolute;
  left: 3%; right: 3%; bottom: 4%;
  height: 16%;
  border-radius: 10px;
  background: linear-gradient(180deg, #8A6238 0%, #5F3F22 100%);
  box-shadow: 0 6px 0 rgba(0,0,0,0.18);
  z-index: 0;
}
.mattress__shadow {
  position: absolute;
  left: 6%; right: 6%; bottom: -2%;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,0.25), transparent 70%);
  filter: blur(2px);
  z-index: 0;
}
.mattress__stack {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column-reverse;
  width: 86%;
  margin-bottom: 12%;
  gap: 2px;
}

.layer {
  position: relative;
  width: 100%;
  min-height: 16px;
  border-radius: 10px;
  transform-origin: bottom center;
  animation: layer-in .45s var(--ease) both;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.45),
    0 2px 0 rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: rgba(255,255,255,0.92);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-body);
}
@keyframes layer-in {
  0%   { transform: translateY(14px) scaleY(.4); opacity: 0; }
  60%  { transform: translateY(-2px) scaleY(1.06); opacity: 1; }
  100% { transform: translateY(0) scaleY(1); opacity: 1; }
}

.layer--gel {
  background: linear-gradient(180deg, #F2B37D 0%, var(--accent-gel) 100%);
  height: 28%;
}
.layer--gel::before {
  /* grid pattern for the comfort layer */
  content: "";
  position: absolute; inset: 4px;
  border-radius: 6px;
  background-image:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.35) 0 2px, transparent 2px 16px),
    repeating-linear-gradient(0deg,  rgba(0,0,0,0.08)   0 2px, transparent 2px 16px);
  opacity: .55;
}
.layer--memo {
  background: linear-gradient(180deg, #C88D5E 0%, var(--accent-memo) 100%);
  height: 22%;
}
.layer--core {
  background: linear-gradient(180deg, #8F6038 0%, var(--accent-core) 100%);
  height: 30%;
}
.layer--base {
  background: linear-gradient(180deg, #5E3B22 0%, var(--accent-base) 100%);
  height: 20%;
}

.layer__label {
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

.sleeper-meta {
  position: relative;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.sleeper-meta__chip {
  background: rgba(217,164,65,0.2);
  color: var(--cocoa);
  border: 1px solid rgba(217,164,65,0.5);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
}
.sleeper-meta__note {
  font-size: 12px;
  color: var(--cocoa-70);
}

/* ===== Panel column ===== */
.panel-col { min-height: 0; display: flex; }
.panel {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--surface-ring);
  border-radius: var(--radius-xl);
  padding: clamp(18px, 2vw, 26px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: panel-fade .35s var(--ease);
}
@keyframes panel-fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel__eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--terracotta);
}
.panel__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(20px, 2.3vw, 26px);
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.panel__lede {
  margin: 0;
  color: var(--cocoa-70);
}

/* --- Sleeper-profile cards (step 1) --- */
.profiles { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 540px) { .profiles { grid-template-columns: repeat(2, 1fr); } }
.profile {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--cream);
  border: 1.5px solid var(--surface-ring);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color .2s var(--ease), transform .15s var(--ease), background .2s var(--ease);
}
.profile:hover { border-color: var(--terracotta); transform: translateY(-1px); }
.profile.is-selected {
  border-color: var(--terracotta);
  background: #FFF5E6;
  box-shadow: 0 0 0 3px rgba(169,82,47,0.1);
}
.profile__icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
  background: rgba(217,164,65,0.2);
}
.profile__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  margin: 6px 0 0;
}
.profile__note { margin: 0; font-size: 12.5px; color: var(--cocoa-70); }

/* --- Layer picker (step 2) --- */
.layer-picker {
  display: grid;
  gap: 10px;
}
.layer-option {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  background: var(--cream);
  border: 1.5px solid var(--surface-ring);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .15s var(--ease);
}
.layer-option:hover { border-color: var(--terracotta); transform: translateY(-1px); }
.layer-option.is-added {
  border-color: var(--avocado);
  background: #F1F5E4;
}
.layer-option.is-recommended::after {
  content: "Recommended";
  position: absolute;
  margin-left: auto;
  right: 52px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mustard-600);
  font-weight: 700;
}
.layer-option {
  position: relative;
}
.swatch {
  width: 44px;
  height: 36px;
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.45), 0 1px 0 rgba(0,0,0,0.08);
}
.swatch--gel  { background: linear-gradient(180deg, #F2B37D, var(--accent-gel)); }
.swatch--memo { background: linear-gradient(180deg, #C88D5E, var(--accent-memo)); }
.swatch--core { background: linear-gradient(180deg, #8F6038, var(--accent-core)); }
.swatch--base { background: linear-gradient(180deg, #5E3B22, var(--accent-base)); }

.layer-option__body h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
}
.layer-option__body p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--cocoa-70);
}
.layer-option__toggle {
  width: 28px; height: 28px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--surface-ring);
  background: var(--surface);
  font-weight: 700;
  color: var(--terracotta);
  transition: all .2s var(--ease);
}
.layer-option.is-added .layer-option__toggle {
  background: var(--avocado);
  color: #fff;
  border-color: var(--avocado);
}

/* --- Talking-points (step 3) --- */
.talking-points {
  display: grid;
  gap: 10px;
}
.tp {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 14px;
  padding: 14px 16px;
  border: 1.5px solid var(--surface-ring);
  border-radius: var(--radius-md);
  background: var(--cream);
}
.tp__rule {
  width: 6px; border-radius: 6px;
  align-self: stretch;
}
.tp--gel  .tp__rule { background: var(--accent-gel); }
.tp--memo .tp__rule { background: var(--accent-memo); }
.tp--core .tp__rule { background: var(--accent-core); }
.tp--base .tp__rule { background: var(--accent-base); }

.tp__kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cocoa-45);
  margin: 0;
}
.tp__script {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15.5px;
  line-height: 1.4;
  color: var(--cocoa);
}
.tp__why {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--cocoa-70);
}

/* --- Check-for-understanding (step 4) --- */
.quiz-q { margin: 0 0 10px; font-weight: 600; font-family: var(--font-display); font-size: 17px; }
.choices { display: grid; gap: 8px; }
.choice {
  text-align: left;
  padding: 12px 14px;
  border: 1.5px solid var(--surface-ring);
  border-radius: var(--radius-md);
  background: var(--cream);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  color: var(--cocoa);
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .15s var(--ease);
}
.choice:hover { border-color: var(--terracotta); transform: translateY(-1px); }
.choice.is-correct { border-color: var(--avocado); background: #EEF4E0; }
.choice.is-wrong   { border-color: #C56A5A; background: #FBEBE7; }
.choice[disabled]  { cursor: default; opacity: .85; }

.feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--surface-ring);
  background: var(--cream);
  display: none;
}
.feedback.is-visible { display: block; animation: panel-fade .25s var(--ease); }
.feedback__title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}
.feedback.is-correct { border-color: var(--avocado); background: #F1F5E4; }
.feedback.is-incorrect { border-color: #C56A5A; background: #FBEBE7; }

/* --- Summary (final step) --- */
.summary__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.summary__stat {
  padding: 12px 14px;
  background: var(--cream);
  border: 1.5px solid var(--surface-ring);
  border-radius: var(--radius-md);
}
.summary__stat p { margin: 0; }
.summary__stat .k {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cocoa-45);
  font-weight: 700;
}
.summary__stat .v {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

/* ===== Footer ===== */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 4px 2px;
}
.footer__hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--cocoa-70);
  font-style: italic;
  flex: 1;
  text-align: center;
}

.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  padding: 10px 20px;
  border-radius: 999px;
  transition: background-color .2s var(--ease), transform .15s var(--ease), color .2s var(--ease);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary {
  background: var(--terracotta);
  color: #fff;
  box-shadow: 0 2px 0 rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.3);
}
.btn--primary:not(:disabled):hover { background: var(--terracotta-600); transform: translateY(-1px); }
.btn--ghost {
  background: transparent;
  color: var(--cocoa);
  border: 1.5px solid var(--surface-ring);
}
.btn--ghost:not(:disabled):hover { border-color: var(--terracotta); color: var(--terracotta); }

/* Focus states for a11y */
.btn:focus-visible,
.profile:focus-visible,
.layer-option:focus-visible,
.choice:focus-visible {
  outline: 3px solid rgba(217,164,65,0.6);
  outline-offset: 2px;
}
