/**
 * Civic Mason initiation shell — no Tailwind; device-native framing.
 */

:root {
  --ink: #0a0c0b;
  --cream: #f4efe6;
  --gold: #e8d4a8;
  --muted: rgba(244, 239, 230, 0.78);
  --muted2: rgba(244, 239, 230, 0.5);
  --radius: 14px;
  --cm-ui-pad: clamp(1.25rem, 4vw, 2rem);
  --cm-max-text: 22rem;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.55;
}

.cm-hidden {
  display: none !important;
}

.cm-root {
  position: relative;
  min-height: 100svh;
  min-height: 100vh;
  overflow: hidden;
  background: var(--ink);
}

/* Phone-first 9:16 feel: letterbox on very wide short viewports */
@media (max-width: 767px) {
  .cm-root {
    max-width: 100%;
  }
}

#cm-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* WebGL sits above photography but is invisible until transition (see app.js class). */
#cm-canvas.cm-canvas--composite {
  opacity: 0;
  transition: opacity 0.45s ease;
}

#cm-canvas.cm-canvas--composite.cm-canvas--transition-active {
  opacity: 1;
}

.cm-root--transitioning .cm-ui {
  pointer-events: none;
}

/* Fallback layers: threshold art + valley overlay (always on for real door imagery) */
.cm-fallback-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: #1a1510;
  background-image: linear-gradient(
      to top,
      rgba(8, 10, 9, 0.88) 0%,
      rgba(8, 10, 9, 0.35) 50%,
      rgba(8, 10, 9, 0.15) 100%
    ),
    url("../assets/hero-mobile.png");
  background-size: cover;
  background-position: calc(50% + var(--cm-parallax-x, 0%)) calc(20% + var(--cm-parallax-y, 0%));
  transition: filter 1.8s ease, opacity 1.8s ease;
}

@media (min-width: 768px) {
  .cm-fallback-bg {
    background-image: linear-gradient(
        to right,
        rgba(8, 10, 9, 0.85) 0%,
        rgba(8, 10, 9, 0.3) 50%,
        rgba(8, 10, 9, 0.12) 100%
      ),
      url("../assets/hero-desktop.png");
    background-position: calc(50% + var(--cm-parallax-x, 0%)) calc(50% + var(--cm-parallax-y, 0%));
  }
}

.cm-fallback-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(18, 28, 24, 0) 0%,
    rgba(18, 36, 30, 0.75) 55%,
    rgba(12, 22, 18, 0.95) 100%
  );
  opacity: 0;
  transition: opacity 1.8s ease;
  pointer-events: none;
}

.cm-fallback-bg--valley::after {
  opacity: 1;
}

.cm-fallback-bg--hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .cm-fallback-bg,
  .cm-fallback-bg::after {
    transition: none;
  }
}

/* UI stack — above photography and canvas */
.cm-ui {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  min-height: 100vh;
  pointer-events: none;
}

.cm-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--cm-ui-pad);
  padding-bottom: max(var(--cm-ui-pad), env(safe-area-inset-bottom));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.55s ease;
}

@media (min-width: 768px) {
  .cm-panel--threshold {
    justify-content: center;
    padding-bottom: 4rem;
  }
}

.cm-root[data-cm-stage="threshold"] .cm-panel[data-cm-panel="threshold"],
.cm-root[data-cm-stage="guided"] .cm-panel[data-cm-panel="guided"],
.cm-root[data-cm-stage="walk"] .cm-panel[data-cm-panel="walk"],
.cm-root[data-cm-stage="paths"] .cm-panel[data-cm-panel="paths"] {
  opacity: 1;
  pointer-events: auto;
}

.cm-panel-inner {
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  text-align: center;
}

.cm-panel--threshold .cm-panel-inner {
  max-width: 28rem;
}

@media (min-width: 768px) {
  .cm-panel--threshold .cm-panel-inner {
    max-width: 32rem;
  }
}

.cm-kicker {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1rem, 3.2vw, 1.35rem);
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 0.35rem;
}

.cm-subkicker {
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  color: var(--muted);
  margin: 0 0 1.5rem;
  font-weight: 400;
}

.cm-title-btn {
  display: inline-block;
  margin: 0 0 0.75rem;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.35rem, 5.5vw, 2.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold);
  text-wrap: balance;
  text-align: center;
  transition: color 0.2s ease, transform 0.2s ease;
}

.cm-title-btn:hover,
.cm-title-btn:focus-visible {
  color: #fff;
  transform: translateY(-1px);
}

.cm-title-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

.cm-tagline {
  font-style: italic;
  font-size: clamp(0.95rem, 2.3vw, 1.1rem);
  color: var(--muted2);
  margin: 0;
}

.cm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.cm-btn-primary {
  background: var(--cream);
  color: var(--ink);
}

.cm-btn-primary:hover,
.cm-btn-primary:focus-visible {
  background: #fff;
}

.cm-btn-ghost {
  background: rgba(15, 20, 18, 0.45);
  color: var(--cream);
  border-color: rgba(232, 212, 168, 0.4);
  backdrop-filter: blur(8px);
}

.cm-btn-ghost:hover,
.cm-btn-ghost:focus-visible {
  border-color: var(--gold);
  color: #fff;
}

.cm-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.cm-guided-copy {
  text-align: left;
  max-width: var(--cm-max-text);
  margin: 0 auto 1.5rem;
  color: var(--muted);
  font-size: clamp(1rem, 2.8vw, 1.12rem);
}

.cm-guided-copy p {
  margin: 0 0 1rem;
}

.cm-guided-copy p:last-child {
  margin-bottom: 0;
}

.cm-walk-zone {
  min-height: 42vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px dashed rgba(232, 212, 168, 0.25);
  margin-bottom: 1rem;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.cm-walk-zone:hover,
.cm-walk-zone:focus-visible {
  border-color: rgba(232, 212, 168, 0.45);
  background: rgba(255, 255, 255, 0.03);
}

.cm-walk-hint {
  font-size: 0.95rem;
  color: var(--gold);
  letter-spacing: 0.04em;
  margin: 0 0 0.35rem;
}

.cm-walk-step {
  font-size: 0.85rem;
  color: var(--muted2);
  margin: 0;
}

.cm-paths-grid {
  display: grid;
  gap: 0.75rem;
  text-align: left;
  max-width: 28rem;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .cm-paths-grid {
    max-width: 40rem;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
}

.cm-path {
  display: block;
  width: 100%;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(232, 212, 168, 0.22);
  background: rgba(12, 16, 14, 0.55);
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.cm-path:hover,
.cm-path:focus-visible {
  border-color: rgba(232, 212, 168, 0.45);
}

.cm-path--suggested {
  border-color: rgba(232, 212, 168, 0.55);
  box-shadow: 0 0 0 1px rgba(232, 212, 168, 0.15);
  background: rgba(24, 32, 28, 0.65);
}

.cm-path-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--gold);
  margin: 0 0 0.35rem;
}

.cm-path-desc {
  font-size: 0.88rem;
  color: var(--muted2);
  margin: 0;
  line-height: 1.45;
}

.cm-path-hint {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold);
  margin: 0 0 0.35rem;
  opacity: 0.85;
}

.cm-path--pulse {
  animation: cm-path-glow 0.35s ease;
}

@keyframes cm-path-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(232, 212, 168, 0.4);
  }
  100% {
    box-shadow: 0 0 24px 2px rgba(232, 212, 168, 0.15);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cm-path--pulse {
    animation: none;
  }
}

.cm-foot {
  position: relative;
  z-index: 3;
  padding: 1rem var(--cm-ui-pad) 1.5rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted2);
}

.cm-foot a {
  color: rgba(232, 212, 168, 0.75);
}

.cm-foot a:hover {
  color: var(--cream);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
