/* ---------------------------------------------------------------
   Control Systems I — room explorer
   Full-bleed photo, dots on the objects, Apple-style panels.
   Committed to one light look; colours are painted explicitly.
   --------------------------------------------------------------- */

:root {
  color-scheme: light;

  --ink:    #1d1d1f;
  --ink-2:  #6e6e73;
  --ink-3:  #a1a1a6;
  --line:   #e4e6ea;
  --blue:   #0071e3;
  --sheet:  rgba(255, 255, 255, 0.92);
  --ground: #0f1114;

  --ph:     #a4560c;
  --ph-bg:  #fdf1e2;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }

/* `hidden` must win over the display rules set further down */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: #fff;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* dragging the room must not select the labels */
  -webkit-user-select: none;
  user-select: none;
}

/* panel text stays selectable */
.sheet, .sheet * { -webkit-user-select: text; user-select: text; }

html:has(.sheet[open]) { overflow: hidden; }

:focus-visible { outline: 2.5px solid #fff; outline-offset: 3px; border-radius: 10px; }

.ph {
  background: var(--ph-bg);
  color: var(--ph);
  border-radius: 4px;
  padding: 0 4px;
  font-style: italic;
}

/* --- top bar --------------------------------------------------- */

.bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  font-size: 15px;
  color: #fff;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.bar > * { pointer-events: auto; }

.rooms-nav { display: flex; gap: 20px; }

.rooms-nav button {
  border: 0;
  padding: 2px 0;
  background: none;
  color: rgba(255, 255, 255, 0.68);
  font: inherit;
  cursor: pointer;
  transition: color .2s;
}
.rooms-nav button:hover { color: #fff; }
.rooms-nav button[aria-current="true"] { color: #fff; font-weight: 600; }

.bar-title { margin: 0; font-weight: 600; white-space: nowrap; }
.bar-right { margin: 0; text-align: right; color: rgba(255, 255, 255, 0.68); }

/* --- stage ----------------------------------------------------- */

.stage {
  position: relative;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  background: var(--ground);
}

.canvas {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

/* two stacked layers so one room can cross-fade into the next */
.shot {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity .55s var(--ease);
  -webkit-user-drag: none;
  user-select: none;
}
.shot.on { opacity: 1; }

.dots, .caption { transition: opacity .3s var(--ease); }
.dots.fading, .caption.fading { opacity: 0; }

.hint {
  position: absolute;
  left: 50%;
  bottom: 96px;
  z-index: 12;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(20, 22, 26, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.92);
  font-size: 13.5px;
  white-space: nowrap;
  pointer-events: none;
  animation: hint-in .6s var(--ease) both;
}
@keyframes hint-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* a gentle top-and-bottom wash so the white UI always has contrast */
.veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.42), rgba(0,0,0,0) 190px),
    linear-gradient(to top,    rgba(0,0,0,.46), rgba(0,0,0,0) 220px);
}

.missing {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(60% 60% at 50% 40%, #2b3038, #14171b 70%);
}
.missing-title { margin: 0; font-size: 19px; font-weight: 600; }
.missing-path {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
  color: #9fb4c8;
}
.missing-help { margin: 8px 0 0; max-width: 40ch; font-size: 14px; color: rgba(255,255,255,.62); }

/* --- dots ------------------------------------------------------ */

.dots { position: absolute; inset: 0; }

.hotspot {
  position: absolute;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  padding: 0;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hotspot .ring {
  position: absolute;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.07);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transform: scale(.82);
  opacity: 0;
  transition: transform .35s var(--ease), opacity .35s var(--ease);
}

.hotspot .core {
  position: relative;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  /* thin dark edge so the dot still reads on a white projector screen */
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.22), 0 3px 14px rgba(0, 0, 0, 0.55);
  transition: transform .3s var(--ease);
}

.hotspot:hover .ring,
.hotspot:focus-visible .ring,
.hotspot.open .ring { transform: scale(1); opacity: 1; }
.hotspot:hover .core,
.hotspot:focus-visible .core { transform: scale(1.15); }

.hotspot .tag {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 6px);
  transform: translate(calc(-50% + var(--shift, 0px)), 6px);
  white-space: nowrap;
  padding: 8px 15px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.hotspot:hover .tag,
.hotspot:focus-visible .tag {
  opacity: 1;
  transform: translate(calc(-50% + var(--shift, 0px)), 0);
}

/* touch devices get no hover, so the labels simply stay visible */
@media (hover: none) {
  .hotspot .tag { opacity: 1; transform: translate(calc(-50% + var(--shift, 0px)), 0); font-size: 13px; padding: 6px 12px; }
  .hotspot .ring { opacity: 1; transform: scale(1); }
}

/* --- arrows & caption ------------------------------------------ */

.arrow {
  position: absolute;
  top: 50%;
  z-index: 12;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  cursor: pointer;
  transition: background .2s, transform .2s var(--ease);
}
.arrow:hover { background: rgba(255, 255, 255, 0.26); }
.arrow:active { transform: scale(.94); }
.arrow svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.prev { left: 22px; }
.next { right: 22px; }

.caption {
  position: absolute;
  left: 0; right: 0; bottom: 26px;
  z-index: 12;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.5);
}
.caption-name { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.caption-sub { margin: 3px 0 0; font-size: 14px; color: rgba(255, 255, 255, 0.74); }

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

.sheet {
  position: fixed;
  margin: 0;
  padding: 0;
  border: 0;
  width: 430px;
  max-width: calc(100% - 32px);
  max-height: calc(100svh - 32px);
  inset: auto;
  left: 16px;
  top: 16px;
  border-radius: 26px;
  background: var(--sheet);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  backdrop-filter: blur(32px) saturate(180%);
  color: var(--ink);
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.55), 0 0 0 0.5px rgba(0, 0, 0, 0.07);
  overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: slide-in .42s var(--ease); }
.sheet::backdrop { background: rgba(10, 12, 15, 0.34); }

@keyframes slide-in { from { opacity: 0; transform: translateX(var(--from, 18px)) scale(.985); } }

.sheet-close {
  position: absolute;
  top: 16px; right: 16px;
  z-index: 2;
  width: 30px; height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink-2);
  cursor: pointer;
}
.sheet-close:hover { background: rgba(0, 0, 0, 0.11); color: var(--ink); }
.sheet-close svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.sheet-body { overflow-y: auto; padding: 30px 30px 28px; overscroll-behavior: contain; }

.s-kicker { margin: 0 0 7px; font-size: 13.5px; font-weight: 600; color: var(--blue); }
.sheet h2 {
  margin: 0;
  padding-right: 34px;
  font-size: 29px;
  line-height: 1.13;
  font-weight: 700;
  letter-spacing: -0.028em;
  text-wrap: balance;
}
.s-lead { margin: 11px 0 0; color: var(--ink-2); font-size: 15.5px; }

.s-list { margin: 22px 0 0; padding: 0; list-style: none; display: grid; }
.s-list li {
  padding: 11px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
  color: var(--ink);
}
.s-list li:first-child { border-top: 0; }

.s-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.s-links a {
  padding: 9px 16px;
  border-radius: 999px;
  background: #f1f2f4;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .2s;
}
.s-links a:hover { background: #e4e6ea; }
/* the first link is always blue; add primary: true to a link in rooms-data.js to make it blue too */
.s-links a:first-child, .s-links a.primary { background: var(--blue); color: #fff; }
.s-links a:first-child:hover, .s-links a.primary:hover { background: #0062c4; }

/* homework tiers: one tinted card per priority, exercises as chips */
.s-tiers { display: grid; gap: 10px; margin-top: 22px; }

.tier {
  --c: #ff375f;  --c2: #ff7a45;  --t: #c8123f;
  padding: 14px 16px 15px;
  border-radius: 18px;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--c) 11%, #fff),
    color-mix(in srgb, var(--c2) 6%, #fff));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 16%, transparent);
}
.tier-should { --c: #ff9500; --c2: #ffcc00; --t: #9a5200; }
.tier-could  { --c: #5e5ce6; --c2: #bf5af2; --t: #4a3fc4; }

.tier-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 11px;
  font-size: 14px;
  font-weight: 650;
  color: var(--t);
}
.tier-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c), var(--c2));
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--c) 20%, transparent);
}

.tier-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.tier-chip {
  padding: 6px 13px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), inset 0 0 0 1px color-mix(in srgb, var(--c) 22%, transparent);
}
/* the must-do exercises get the filled treatment */
.tier-must .tier-chip {
  background: linear-gradient(135deg, #e8264e, #f4512c);
  color: #fff;
  box-shadow: 0 2px 8px -2px rgba(232, 38, 78, 0.45);
}
.tier-chip .ph { background: none; color: inherit; padding: 0; opacity: .75; }

/* stepping through the homework of past weeks */
.s-week {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
}
.week-label { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.week-step {
  width: 36px; height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
  cursor: pointer;
}
.week-step:hover { color: var(--blue); }
.week-step:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 2px; border-radius: 50%; }
.week-step:disabled { background: none; box-shadow: none; color: var(--ink-2); opacity: .4; cursor: default; }
.week-step svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.s-weeks { display: grid; margin-top: 10px; }
.week-pane { grid-area: 1 / 1; margin-top: 0; align-content: start; visibility: hidden; opacity: 0; transition: opacity .2s; }
.week-pane.on { visibility: visible; opacity: 1; }
.tier-none {
  margin: 0;
  padding: 18px 16px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.tier-none span { display: block; margin-top: 3px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); opacity: .8; }

/* a link whose URL has not been filled in yet */
.s-links a[data-placeholder],
.s-links a[data-placeholder]:hover {
  background: var(--ph-bg);
  color: var(--ph);
  box-shadow: inset 0 0 0 1px rgba(164, 86, 12, 0.3);
  cursor: default;
}

.s-note {
  margin: 22px 0 0;
  padding: 13px 15px;
  border-radius: 14px;
  background: #f5f5f7;
  color: var(--ink-2);
  font-size: 14.5px;
}

/* --- edit mode ------------------------------------------------- */

.editbar {
  position: fixed;
  left: 16px; bottom: 16px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(20, 22, 26, 0.86);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: #fff;
  font-size: 13px;
}
.editbar output {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: #7fd4ff;
}
.editbar button {
  border: 0;
  border-radius: 999px;
  padding: 6px 13px;
  background: #fff;
  color: #14161a;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
body.editing .hotspot { cursor: grab; }
body.editing .hotspot:active { cursor: grabbing; }

/* --- small screens --------------------------------------------- */

@media (max-width: 720px) {
  /* only phones drag the room around */
  .stage { touch-action: none; }
  .canvas { cursor: grab; }
  .canvas.dragging { cursor: grabbing; }
  .bar { padding: 14px 16px; font-size: 13.5px; grid-template-columns: 1fr auto; }
  .bar-right { display: none; }
  .rooms-nav { gap: 14px; }
  .arrow { width: 38px; height: 38px; margin-top: -19px; }
  .prev { left: 12px; }
  .next { right: 12px; }
  .caption-name { font-size: 18px; }
  .hint { bottom: 84px; }
  .hotspot { width: 40px; height: 40px; margin: -20px 0 0 -20px; }

  .sheet {
    inset: auto 0 0 0 !important;
    width: 100%;
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    max-height: 86svh;
  }
  .sheet[open] { animation: slide-up .42s var(--ease); }
  .sheet-body { padding: 26px 20px calc(24px + env(safe-area-inset-bottom)); }
  .sheet-body::before {
    content: "";
    display: block;
    width: 36px; height: 5px;
    margin: -12px auto 16px;
    border-radius: 3px;
    background: #d2d2d7;
  }
  .sheet h2 { font-size: 25px; }
}

@keyframes slide-up { from { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .shot { opacity: 1; }
}
