/* The front-door lantern (door v2, 2026-07-09): three.js lamp on a canvas,
 * DOM overlay for everything readable. Treaty v2.1 (operator-revised
 * 2026-07-09 evening): each pane wears a 2D non-interactive IMAGE of its
 * card painted on the mesh, and the DOM overlay — still the only
 * functional surface — turns invisible and sits fitted over the facing
 * card (.is-skinned below). Without JS or WebGL there is no skin, the
 * overlay stays the visible card, and the plain-links row is the way in. */
/* Round 9: the LIGHT FIELD — not a generic backdrop fade. The lamp JS
 * projects the lantern's position to page pixels (--glow-x/--glow-y) and
 * writes the light's rgb + dimmer; illumination is strongest within the
 * lantern's influence and falls off outward, with a second lobe where the
 * light pools on the floor. Light off = plain limestone. */
.door-page {
  --glow-x: 50%;
  --glow-y: 34%;
  --floor-y: 72%;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  align-content: start;
  padding: 12px 12px 20px;
  color: var(--ink);
  /* round 10: less page-wide haze — the lantern's own light defines the
   * local atmosphere; the field is a supporting cast, not the lighting */
  background:
    radial-gradient(circle at var(--glow-x) var(--glow-y),
      rgba(var(--lamp-r), var(--lamp-g), var(--lamp-b),
           calc(.32 * var(--lamp-dim))),
      rgba(var(--lamp-r), var(--lamp-g), var(--lamp-b),
           calc(.12 * var(--lamp-dim))) 26%,
      transparent 30rem),
    radial-gradient(ellipse 40rem 11rem at var(--glow-x) var(--floor-y),
      rgba(var(--lamp-r), var(--lamp-g), var(--lamp-b),
           calc(.2 * var(--lamp-dim))),
      transparent 70%),
    var(--ground);
}

.door-lamp {
  width: min(100%, 720px);
  margin: 0 auto;
}

/* Round 6: smaller still — a nameplate, not a marquee. Besley carries the
 * shell voice; one brass rule, one flat shadow. */
.door-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 8px 26px 6px;
  padding: 9px 14px;
  color: var(--paper);
  background:
    linear-gradient(135deg, rgba(195, 154, 70, .14), transparent 42%),
    var(--ink);
  border: 1px solid rgba(195, 154, 70, .45);
  border-bottom: 3px solid var(--gold);
  border-radius: 0 0 16px 16px;
  box-shadow: 0 4px 0 rgba(138, 106, 63, .36);
  text-align: left;
}

.door-header::after,
.door-header::before {
  content: none;
}

.door-header .brand-lantern {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 4px 10px rgba(214, 162, 58, .22));
}

.door-header h1 {
  margin: 0;
  font-family: var(--font-shell);
  font-size: clamp(1.3rem, 5.4vw, 1.6rem);
  font-weight: 900;
  letter-spacing: .075em;
  line-height: 1;
  text-transform: uppercase;
}

.door-header p {
  margin: 3px 0 0;
  color: #dfc991;
  font-size: .8rem;
  line-height: 1.2;
}

/* ---- the stage: canvas lamp behind, readable overlay in front.
 * Round 9: the old control row's dead space is gone — the stage owns the
 * full column and the lantern hangs low in it, shadow unclipped. ---- */
.lamp-stage {
  position: relative;
  height: min(82vh, 780px);
  min-height: 560px;
  touch-action: pan-y;
}

.lamp-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.lamp-overlay {
  position: absolute;
  left: 50%;
  top: 52%;
  width: min(72vw, 260px);
  min-height: 300px;
  translate: -50% -50%;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 26px 18px 18px;
  color: var(--ink);
  background:
    linear-gradient(
      145deg,
      rgba(255, 255, 246, .88),
      rgba(224, 218, 198, .76)
    );
  border: 3px solid rgba(20, 18, 15, .88);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 2px rgba(138, 106, 63, .42),
    0 18px 36px rgba(23, 23, 23, .24);
  transition: opacity 200ms ease;
}

.lamp-overlay.is-turning {
  opacity: .18;
  pointer-events: none;
}

.lamp-overlay h2 {
  margin: 0;
  font-family: var(--font-panel);
  font-size: clamp(1.35rem, 6.4vw, 1.9rem);
  line-height: .98;
}

.lamp-overlay > p {
  margin: 0;
  color: #3a332a;
  font-size: .92rem;
}

.panel-kicker {
  margin: 0;
  color: var(--bronze);
  font-family: var(--font-label);
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* the doorplate meta line (Lantern Directive: terse, muted) */
.panel-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-family: var(--font-label);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
}

/* entering a face: the card brightens for ~150ms before the route changes
 * (flat mode + a visual assist over the WebGL brighten) */
.lamp-overlay.is-entering {
  transition: filter 150ms ease;
  filter: brightness(1.3);
}

@media (prefers-reduced-motion: reduce) {
  .lamp-overlay.is-entering {
    transition: none;
    filter: none;
  }
}

.panel-preview {
  display: grid;
  gap: 3px;
  margin-top: 4px;
  padding: 10px;
  background: rgba(255, 248, 232, .72);
  border: 1px solid rgba(23, 23, 23, .20);
  border-radius: 14px;
}

.panel-preview span {
  color: var(--muted);
  font-family: var(--font-label);
  font-size: .64rem;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.panel-preview strong {
  font-size: .92rem;
}

.panel-cta {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  padding: 10px 12px;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-bottom: 4px solid var(--bronze);
  border-radius: 12px;
  font-family: var(--font-label);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .045em;
  text-decoration: none;
  text-transform: uppercase;
}

/* Corner ornament on the overlay card: opens the settings dialog. */
.panel-boss {
  position: absolute;
  right: 0;
  top: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  cursor: pointer;
}

.panel-boss::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 32%, rgba(255, 248, 232, .9) 0 3px, transparent 4px),
    radial-gradient(circle, var(--gold) 0 58%, var(--bronze) 62% 100%);
  border: 2px solid rgba(23, 23, 23, .7);
  box-shadow: 0 1px 3px rgba(23, 23, 23, .4);
}

/* ---- skinned mode: the card is an image on the pane; this overlay is the
 * invisible functional twin fitted over it by fitOverlay() in
 * door-lamp-3d.js. Interactive rects (CTA, boss) mirror the painter's
 * layout fractions — keep them in sync or taps land beside the painted
 * controls. Text stays in the tree, transparent, for screen readers. ---- */
.lamp-stage.is-skinned .lamp-overlay {
  translate: none;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: none;
  border-color: transparent;
  box-shadow: none;
  pointer-events: none;      /* flicks pass through; controls stay live */
}

.lamp-stage.is-skinned .lamp-overlay a,
.lamp-stage.is-skinned .lamp-overlay button {
  pointer-events: auto;
}

.lamp-stage.is-skinned .lamp-overlay h2,
.lamp-stage.is-skinned .lamp-overlay > p,
.lamp-stage.is-skinned .panel-kicker,
.lamp-stage.is-skinned .panel-preview span,
.lamp-stage.is-skinned .panel-preview strong {
  color: transparent;
}

.lamp-stage.is-skinned .panel-preview {
  background: none;
  border-color: transparent;
}

.lamp-stage.is-skinned .panel-boss::before {
  opacity: 0;
}

.lamp-stage.is-skinned .panel-cta {
  position: absolute;
  left: 0;                  /* = painter plaque: full bleed, rib to rib */
  right: 0;
  bottom: 1.5%;             /* = painter ctaBottom */
  height: 11.5%;            /* = painter ctaH */
  min-height: 44px;         /* hit target may exceed the painted plaque */
  margin: 0;
  color: transparent;
  background: transparent;
  border-color: transparent;
}

/* invisible controls still need a visible keyboard-focus ring */
.lamp-stage.is-skinned .panel-cta:focus-visible,
.lamp-stage.is-skinned .panel-boss:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 12px;
}

/* flat mode: no WebGL — the overlay simply sits on the ground */
.lamp-stage.is-flat {
  min-height: 360px;
  height: auto;
  padding: 20px 0;
}

.lamp-stage.is-flat .lamp-overlay {
  position: static;
  translate: none;
  margin: 0 auto;
}

/* Round 9: no side rotate controls — rotation is swipe/drag on the stage
 * (arrow keys remain for keyboards); the facing change is announced by
 * the sr-only live region. */

/* The facing label is announced, not shown (round 6): the card title on
 * the glass already names the panel; a .sr-only live region carries it to
 * screen readers. The freed floor belongs to the lamp's shadow. */

/* Sandwich menu in the masthead (round 8) — replaces the bottom walk-row.
 * A native <details>, so it IS the no-JS / old-phone floor: the links are
 * always in the DOM and the disclosure works without a line of script.
 * Animation is CSS-only. */
.door-menu {
  position: relative;
  margin-left: auto;
}

.door-menu summary {
  width: 44px;
  height: 44px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  list-style: none;
  cursor: pointer;
  border: 1px solid rgba(195, 154, 70, .45);
  border-radius: 10px;
}

.door-menu summary::-webkit-details-marker {
  display: none;
}

.door-menu summary span {
  width: 20px;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
  transition: transform 180ms ease, opacity 120ms ease;
}

.door-menu[open] summary span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.door-menu[open] summary span:nth-child(2) {
  opacity: 0;
}

.door-menu[open] summary span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

.door-menu-links {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  z-index: 40;
  min-width: 200px;
  display: grid;
  padding: 8px;
  background: var(--ink);
  border: 1px solid rgba(195, 154, 70, .5);
  border-bottom: 3px solid var(--gold);
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(23, 23, 23, .35);
  transform-origin: top right;
}

.door-menu[open] .door-menu-links {
  animation: door-menu-unfold 180ms ease;
}

@keyframes door-menu-unfold {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(.96);
  }
}

.door-menu-links a {
  padding: 10px 12px;
  color: var(--paper);
  border-radius: 8px;
  font-family: var(--font-control);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-decoration: none;
  text-transform: uppercase;
}

.door-menu-links a:hover,
.door-menu-links a:focus-visible {
  background: rgba(195, 154, 70, .18);
  color: #f7dca3;
}

/* "How to use" lives IN the menu as a visible, touch-friendly disclosure —
 * the household rule is visible hints, never hover tooltips (phones). */
.door-help {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(195, 154, 70, .35);
}

.door-help summary {
  padding: 10px 12px;
  color: #dfc991;
  cursor: pointer;
  white-space: nowrap;
  border-radius: 8px;
  font-family: var(--font-control);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.door-help summary:hover,
.door-help summary:focus-visible {
  background: rgba(195, 154, 70, .18);
}

.door-help ul {
  margin: 4px 0 6px;
  padding: 0 12px 0 26px;
  color: var(--paper);
  font-size: .82rem;
  line-height: 1.45;
}

.door-help li {
  margin-bottom: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .door-menu[open] .door-menu-links {
    animation: none;
  }

  .door-menu summary span {
    transition: none;
  }
}

/* ---- settings overlay: translucent, the lamp stays visible behind it ---- */
.lamp-dialog {
  width: min(100%, 460px);
  margin: auto auto 0;
  padding: 0;
  color: var(--ink);
  background: rgba(241, 232, 208, .82);
  border: 1px solid rgba(23, 23, 23, .35);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 32px rgba(23, 23, 23, .25);
}

.lamp-dialog::backdrop {
  background: rgba(23, 23, 23, .08);
}

.lamp-dialog-inner {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.lamp-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lamp-dialog-head h2 {
  margin: 0;
  font-family: var(--font-label);
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.lamp-close {
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  border: 1px solid rgba(23, 23, 23, .3);
  border-radius: 999px;
  cursor: pointer;
  font-size: 1rem;
}

.lamp-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.lamp-switch,
.lamp-control {
  min-height: 44px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px 9px;
  background: rgba(255, 248, 232, .68);
  border: 1px solid rgba(23, 23, 23, .18);
  border-radius: 12px;
}

.lamp-switch {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.lamp-switch span,
.lamp-control span {
  color: var(--bronze);
  font-family: var(--font-label);
  font-size: .64rem;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.lamp-control input,
.lamp-control select {
  width: 100%;
  min-height: 30px;
  color: var(--ink);
}

.lamp-switch input {
  width: 20px;
  height: 20px;
  accent-color: var(--bronze);
}

.lamp-reset {
  grid-column: 1 / -1;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-bottom: 4px solid var(--bronze);
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-label);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.lamp-reset:active {
  transform: translateY(1px);
  border-bottom-width: 3px;
}

@media (min-width: 700px) {
  .lamp-dialog {
    margin: auto;
    border-radius: 18px;
  }
}

@media (max-width: 390px) {
  .lamp-stage {
    min-height: 440px;
  }

  .lamp-overlay {
    width: min(78vw, 244px);
    padding: 24px 15px 16px;
  }

  .lamp-overlay > p {
    font-size: .86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lamp-overlay {
    transition: none;
  }
}

/* Quick actions (IA 2026-07-10): Post and Ask Epistable are ACTIONS in
 * the masthead, not lantern faces — the faces are domains. */
.masthead-actions {
  display: flex;
  gap: 8px;
  flex-basis: 100%;
  justify-content: center;
  margin-top: 8px;
}

.door-header {
  flex-wrap: wrap;
}

.masthead-action {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  color: var(--paper);
  background: rgba(255, 248, 232, .08);
  border: 1px solid rgba(195, 154, 70, .45);
  border-bottom-width: 3px;
  border-radius: 999px;
  font-family: var(--font-control);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .045em;
  text-decoration: none;
  text-transform: uppercase;
}

.masthead-action-primary {
  color: var(--ink);
  background: var(--gold);
  border-color: var(--gold);
}
