/* DowDomes landing — the 3D app village.
   The scene fills the viewport; brand, tools, pins, dock and sheet float on
   top as glass panels. Without WebGL/JS (.no-scene) the dock turns into a
   plain grid of app cards, so every link keeps working. */

:root {
  --ink: #0d2233;
  --ink-soft: #3f586b;
  --glass: rgba(255, 255, 255, 0.66);
  --glass-hi: rgba(255, 255, 255, 0.9);
  --glass-line: rgba(255, 255, 255, 0.78);
  --glass-shadow: 0 14px 34px rgba(18, 44, 72, 0.16), 0 2px 6px rgba(18, 44, 72, 0.08);
  --sky-a: #6fb2ea;
  --sky-b: #cde9fb;
  --sky-c: #eef6fb;
  --brand-dot: #2f9e5b;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

:root[data-phase="night"] {
  --ink: #eef3ff;
  --ink-soft: #b7c4e2;
  --glass: rgba(14, 22, 46, 0.56);
  --glass-hi: rgba(18, 28, 58, 0.86);
  --glass-line: rgba(255, 255, 255, 0.14);
  --glass-shadow: 0 14px 34px rgba(0, 0, 0, 0.36), 0 2px 6px rgba(0, 0, 0, 0.2);
  --sky-a: #071330;
  --sky-b: #1b2b55;
  --sky-c: #0f1b3a;
  --brand-dot: #ffd166;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, var(--sky-a) 0%, var(--sky-b) 58%, var(--sky-c) 100%);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.icons { position: absolute; width: 0; height: 0; overflow: hidden; }

.icons symbol, .tool svg, .app__icon svg, .pin__icon svg, .sheet__icon svg, .curtain__icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icons .fill { fill: currentColor; stroke: none; }

/* ---------- scene ---------- */
.scene {
  position: fixed;
  inset: 0;
  opacity: 0;
  transition: opacity 1.4s ease;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.scene canvas { display: block; width: 100%; height: 100%; outline: none; }
.scene-ready .scene { opacity: 1; }
.scene.is-pointing { cursor: pointer; }
.scene.is-dragging { cursor: grabbing; }

/* Soft diorama vignette. */
.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(10, 30, 60, 0.16) 100%);
}

/* ---------- brand ---------- */
.brand {
  position: fixed;
  z-index: 5;
  top: calc(1.3rem + var(--safe-t));
  left: clamp(1rem, 3vw, 2.4rem);
  pointer-events: none;
  text-shadow: 0 1px 14px rgba(255, 255, 255, 0.55);
}

[data-phase="night"] .brand { text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5); }

.brand__eyebrow {
  margin: 0 0 0.35rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand__title {
  margin: 0;
  font-family: Anton, Impact, "Arial Narrow Bold", sans-serif;
  font-size: clamp(2.5rem, 5.6vw, 4.6rem);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.brand__dot { color: var(--brand-dot); transition: color 0.6s; }

.brand__tagline {
  max-width: 21rem;
  margin: 0.6rem 0 0;
  color: var(--ink-soft);
  font-size: clamp(0.88rem, 1.2vw, 1rem);
  font-weight: 650;
  line-height: 1.4;
}

/* ---------- tools ---------- */
.tools {
  position: fixed;
  z-index: 6;
  top: calc(1.2rem + var(--safe-t));
  right: clamp(1rem, 3vw, 2rem);
  display: flex;
  gap: 0.6rem;
}

.tool {
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  padding: 0;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: var(--glass-shadow);
  color: var(--ink);
  cursor: pointer;
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  transition: transform 0.2s ease, background 0.4s;
}

.tool:hover { transform: translateY(-2px); }
.tool:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.tool svg { width: 1.3rem; height: 1.3rem; }
.tool__moon { display: none; }
[data-phase="night"] .tool__sun { display: none; }
[data-phase="night"] .tool__moon { display: block; }

/* ---------- pins over the houses ---------- */
.pins {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.pin {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  pointer-events: auto;
  will-change: transform;
  transition: opacity 0.35s ease;
}

.pin.is-hidden { opacity: 0; pointer-events: none; }

.pin__bubble {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  max-width: 17rem;
  padding: 0.3rem 0.8rem 0.3rem 0.3rem;
  border: 1px solid var(--glass-line);
  border-radius: 1.1rem;
  background: var(--glass-hi);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transform-origin: 50% 100%;
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.25), box-shadow 0.3s;
}

.pin.is-active { z-index: 5000 !important; }
.pin.is-active .pin__bubble {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent), var(--glass-shadow);
}

.pin__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
  color: #fff;
}

.pin__icon svg { width: 1.02rem; height: 1.02rem; stroke-width: 2.2; }

.pin__label { display: flex; flex-direction: column; min-width: 0; padding-top: 0.3rem; }

.pin__name {
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.15;
  white-space: nowrap;
}

.pin__more {
  display: grid;
  grid-template-rows: 0fr;
  max-width: 0;
  opacity: 0;
  transition: grid-template-rows 0.32s ease, max-width 0.32s ease, opacity 0.25s ease;
}

.pin__more > span { overflow: hidden; }
.pin.is-active .pin__more { grid-template-rows: 1fr; max-width: 14rem; opacity: 1; }

.pin__tag {
  display: block;
  margin-top: 0.3rem;
  color: var(--accent);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

[data-phase="night"] .pin__tag { color: color-mix(in srgb, var(--accent) 45%, white); }

.pin__desc {
  display: block;
  width: 13.5rem;
  margin-top: 0.15rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.38;
}

.pin__cta {
  display: inline-block;
  margin: 0.4rem 0 0.2rem;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 900;
}

.pin__stem {
  width: 2px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(var(--glass-hi), rgba(255, 255, 255, 0));
}

.pin__stem::after {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  margin: 13px 0 0 -2px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--glass-hi);
}

/* ---------- dock ---------- */
.dock {
  position: fixed;
  z-index: 5;
  bottom: calc(1rem + var(--safe-b));
  left: 50%;
  max-width: calc(100vw - 1.5rem);
  transform: translateX(-50%);
}

.dock__list {
  display: flex;
  gap: 0.3rem;
  margin: 0;
  padding: 0.42rem;
  overflow-x: auto;
  border: 1px solid var(--glass-line);
  border-radius: 1.35rem;
  background: var(--glass);
  box-shadow: var(--glass-shadow);
  list-style: none;
  scrollbar-width: none;
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
}

.dock__list::-webkit-scrollbar { display: none; }
.dock__item { flex: none; }

.app {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.38rem 0.85rem 0.38rem 0.38rem;
  border-radius: 1rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.app:hover, .app.is-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  transform: translateY(-3px);
}

.app:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app__icon {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 0.75rem;
  background: var(--accent);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
  color: #fff;
}

.app__icon svg { width: 1.2rem; height: 1.2rem; }

.app__text { display: flex; flex-direction: column; line-height: 1.15; }

.app__tag {
  color: var(--ink-soft);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.app__name { font-size: 0.86rem; font-weight: 850; }
.app__desc { display: none; }

/* ---------- touch sheet ---------- */
.sheet {
  position: fixed;
  z-index: 7;
  right: 0.75rem;
  bottom: calc(5.9rem + var(--safe-b));
  left: 0.75rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem 0.85rem;
  align-items: center;
  padding: 0.85rem;
  border: 1px solid var(--glass-line);
  border-radius: 1.25rem;
  background: var(--glass-hi);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15), opacity 0.25s ease, visibility 0.3s;
}

.sheet[hidden] {
  display: grid;
  visibility: hidden;
  opacity: 0;
  transform: translateY(1.2rem);
  pointer-events: none;
}

.sheet__icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 1rem;
  background: var(--accent);
  color: #fff;
}

.sheet__icon svg { width: 1.6rem; height: 1.6rem; }
.sheet__text p { margin: 0; }

.sheet__tag {
  color: var(--accent);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

[data-phase="night"] .sheet__tag { color: color-mix(in srgb, var(--accent) 45%, white); }
.sheet__name { font-size: 1.08rem; font-weight: 900; }

.sheet__desc {
  margin-top: 0.15rem !important;
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.38;
}

.sheet__go {
  grid-column: 1 / -1;
  padding: 0.8rem 1rem;
  border-radius: 0.95rem;
  background: var(--accent);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  color: #fff;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.sheet__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

/* ---------- hint, footer, loader ---------- */
.hint {
  position: fixed;
  z-index: 4;
  bottom: calc(5.5rem + var(--safe-b));
  left: 50%;
  margin: 0;
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  background: var(--glass);
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 750;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: opacity 0.6s ease;
}

.scene-ready .hint { opacity: 1; transition-delay: 2.8s; }
.scene-ready .hint.is-gone { opacity: 0; transition-delay: 0s; }
.hint--touch { display: none; }

@media (hover: none) {
  .hint--fine { display: none; }
  .hint--touch { display: inline; }
}

.foot {
  position: fixed;
  z-index: 4;
  right: 1.1rem;
  bottom: calc(0.35rem + var(--safe-b));
  font-size: 0.68rem;
  font-weight: 750;
}

.foot a { color: var(--ink-soft); text-decoration: none; opacity: 0.75; }
.foot a:hover { opacity: 1; }

.loader {
  position: fixed;
  z-index: 8;
  top: 50%;
  left: 50%;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: var(--glass-hi);
  box-shadow: var(--glass-shadow);
  font-size: 0.9rem;
  font-weight: 800;
  transform: translate(-50%, -50%);
  transition: opacity 0.6s ease;
}

.scene-ready .loader, .no-scene .loader { opacity: 0; pointer-events: none; }

.loader__dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--brand-dot);
  animation: dot 0.9s ease-in-out infinite alternate;
}

@keyframes dot {
  from { opacity: 0.45; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1.1); }
}

/* ---------- portal curtain (entering a house) ---------- */
.curtain {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.9rem;
  background: radial-gradient(circle at var(--cx, 50%) var(--cy, 50%),
    color-mix(in srgb, var(--accent, #2f9e5b) 82%, white), var(--accent, #2f9e5b) 70%);
  color: #fff;
  clip-path: circle(0% at var(--cx, 50%) var(--cy, 50%));
  pointer-events: none;
  transition: clip-path 0.7s cubic-bezier(0.7, 0, 0.3, 1);
}

.curtain.is-on { clip-path: circle(150% at var(--cx, 50%) var(--cy, 50%)); pointer-events: auto; }

.curtain__icon {
  display: grid;
  place-items: center;
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 1.4rem;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.curtain__icon svg { width: 2.3rem; height: 2.3rem; }

.curtain__name {
  margin: 0;
  font-family: Anton, Impact, sans-serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .brand__title { font-size: 2.35rem; }
  .brand__eyebrow { font-size: 0.64rem; }
  .brand__tagline { max-width: 13.5rem; font-size: 0.8rem; }
  .tool { width: 2.6rem; height: 2.6rem; }

  .dock { right: 0.6rem; left: 0.6rem; max-width: none; transform: none; }
  .dock__list { gap: 0.15rem; padding: 0.35rem; scroll-snap-type: x proximity; }
  .dock__item { scroll-snap-align: start; }

  .app {
    flex-direction: column;
    gap: 0.28rem;
    min-width: 4.5rem;
    padding: 0.4rem 0.3rem;
    white-space: normal;
  }

  .app__text { align-items: center; text-align: center; }
  .app__tag { display: none; }
  .app__name { max-width: 4.6rem; overflow: hidden; font-size: 0.66rem; text-overflow: ellipsis; white-space: nowrap; }
  .app__icon { width: 2rem; height: 2rem; }

  .pin__bubble { padding: 0.22rem; border-radius: 999px; }
  .pin__label { display: none; }
  .pin__icon { width: 1.6rem; height: 1.6rem; }
  .pin__icon svg { width: 0.95rem; height: 0.95rem; }

  .hint { bottom: calc(6.3rem + var(--safe-b)); font-size: 0.68rem; }
  .foot { display: none; }
}

@media (min-width: 761px) {
  .sheet { right: auto; left: 50%; width: 25rem; transform: translateX(-50%); bottom: calc(6.4rem + var(--safe-b)); }
  .sheet[hidden] { transform: translate(-50%, 1.2rem); }
}

/* Phones in landscape: keep the scene visible. */
@media (max-height: 520px) and (min-width: 480px) {
  .brand { top: calc(0.7rem + var(--safe-t)); }
  .brand__eyebrow, .brand__tagline, .hint { display: none; }
  .brand__title { font-size: 1.9rem; }
  .tools { top: calc(0.6rem + var(--safe-t)); }
  .tool { width: 2.4rem; height: 2.4rem; }
  .dock { bottom: calc(0.5rem + var(--safe-b)); }
  .app { padding: 0.28rem; }
  .app__text { display: none; }
  .app__icon { width: 2rem; height: 2rem; }
  .sheet { bottom: calc(4rem + var(--safe-b)); }
  .foot { display: none; }
}

/* ---------- fallback: plain app grid ---------- */
.no-scene body { overflow: auto; }
.no-scene .scene, .no-scene .tools, .no-scene .pins, .no-scene .hint, .no-scene .sheet { display: none; }

.no-scene .brand {
  position: static;
  max-width: 74rem;
  margin: 0 auto;
  padding: calc(2.5rem + var(--safe-t)) clamp(1rem, 4vw, 3rem) 0;
}

.no-scene .dock {
  position: static;
  max-width: 74rem;
  margin: 2rem auto 3rem;
  padding: 0 clamp(1rem, 4vw, 3rem);
  transform: none;
}

.no-scene .dock__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr));
  gap: 1rem;
  padding: 0;
  overflow: visible;
  border: 0;
  background: none;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.no-scene .app {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.9rem;
  height: 100%;
  padding: 1.1rem;
  border: 1px solid var(--glass-line);
  border-radius: 1.15rem;
  background: var(--glass-hi);
  box-shadow: var(--glass-shadow);
  white-space: normal;
}

.no-scene .app__icon { width: 3rem; height: 3rem; border-radius: 1rem; }
.no-scene .app__icon svg { width: 1.6rem; height: 1.6rem; }
.no-scene .app__text { align-items: flex-start; text-align: left; }
.no-scene .app__tag { display: block; }
.no-scene .app__name { max-width: none; overflow: visible; font-size: 1.1rem; white-space: normal; }
.no-scene .app__desc { display: block; margin-top: 0.35rem; color: var(--ink-soft); font-size: 0.88rem; font-weight: 550; line-height: 1.45; }
.no-scene .foot { position: static; display: block; padding: 0 0 2rem; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .scene, .pin, .pin__bubble, .pin__more, .app, .tool, .sheet, .hint, .curtain { transition-duration: 0.01s !important; }
  .loader__dot { animation: none; }
}
