/* ============================================================
   MARM TRADING — ecosystem shell
   Gateway · wing environments. Same order, one architecture.
   ============================================================ */

:root {
  --graphite:   #101113;
  --charcoal:   #15171a;
  --stone-dark: #1c1f23;
  --line:       rgba(232, 226, 214, 0.10);
  --line-soft:  rgba(232, 226, 214, 0.06);
  --ivory:      #e8e2d6;
  --marble:     #b9b3a6;
  --stone-mute: #8a8475;
  --bronze:     #8c7351;
  --bronze-lit: #a68e67;
  --bronze-dim: #6e5a40;
  --ember:      #d8c9a8;
  --font-d: "Cormorant", "Times New Roman", serif;
  --font-b: "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(.22, .8, .26, .99);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--graphite);
  color: var(--marble);
  font-family: var(--font-b);
  font-weight: 300;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
}

::selection { background: var(--bronze-dim); color: var(--ivory); }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-d); font-weight: 500; color: var(--ivory); }

:focus-visible { outline: 1px solid var(--bronze); outline-offset: 3px; }

.grain {
  position: fixed; inset: -50%;
  width: 200%; height: 200%;
  pointer-events: none;
  z-index: 999;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 9s steps(6) infinite;
}
@keyframes grain {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-2%,2%); }
  40% { transform: translate(2%,-1%); }
  60% { transform: translate(-1%,-2%); }
  80% { transform: translate(1%,2%); }
}

/* ============================================================
   GATEWAY
   ============================================================ */
.gate {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(140,115,81, calc(.10 * var(--ignite, 0))), transparent 65%),
    var(--graphite);
}

/* ---------- ember field (energy flowing into the seal) ---------- */
.gate__embers {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s var(--ease);
}
.gate__embers.is-live { opacity: 1; }

/* ---------- release flare (the activation bloom) ---------- */
.gate__flare {
  position: absolute;
  left: 50%; top: 46%;
  width: 60vmax; height: 60vmax;
  transform: translate(-50%, -50%) scale(.35);
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle, rgba(216, 201, 168, .9) 0%, rgba(140, 115, 81, .28) 26%, transparent 62%);
}
.gate__flare.is-burst { animation: flare 1.25s var(--ease) forwards; }
@keyframes flare {
  0%   { opacity: 0;   transform: translate(-50%, -50%) scale(.30); }
  22%  { opacity: .85; }
  100% { opacity: 0;   transform: translate(-50%, -50%) scale(1.5); }
}

/* ---------- ignition stage ---------- */
.gate__stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 34px;
  cursor: pointer;
  z-index: 3;
  transition: opacity 1s var(--ease), visibility 1s;
}
.gate__stage.is-open { opacity: 0; visibility: hidden; pointer-events: none; }

.gate__seal {
  width: clamp(150px, 30vw, 220px);
  height: auto;
  color: var(--bronze);
  opacity: 0;
  transform: scale(.96);
  filter: drop-shadow(0 0 0 rgba(216, 201, 168, 0));
  transition:
    opacity 1.4s var(--ease),
    transform 1.6s var(--ease),
    filter 1.6s var(--ease);
}

/* phase: appear — the symbol materializes, dim */
.is-appear .gate__seal { opacity: .35; transform: scale(1); }

/* phase: spark — first energy traces the rings */
.is-spark .gate__seal { opacity: .55; }

/* phase: charge — light builds inside the symbol */
.is-charge .gate__seal {
  opacity: .85;
  filter: drop-shadow(0 0 18px rgba(216, 201, 168, .25));
}

/* phase: peak — contained maximum */
.is-peak .gate__seal {
  opacity: 1;
  transform: scale(1.04);
  filter: drop-shadow(0 0 38px rgba(216, 201, 168, .55));
  transition-duration: .7s, .7s, .7s;
}

/* phase: hold — a held breath. The seal tightens inward, glow concentrates,
   the resonance stills. Maximum contained tension before release. */
.is-hold .gate__seal {
  animation: none;
  transform: scale(.985);
  filter: drop-shadow(0 0 50px rgba(216, 201, 168, .72));
  transition-duration: .6s, .6s, .6s;
}

/* phase: release — the seal separates, the gate opens */
.is-release .gate__seal {
  opacity: 0;
  filter: drop-shadow(0 0 60px rgba(216, 201, 168, 0));
  transition-duration: 1.1s, 1.1s, 1.1s;
}

/* the seal as a living mechanism — groups counter-rotate, driven by JS (--ang),
   and separate on release via JS (--sep / --sep-core) while dissolving */
.gate__seal g { transform-box: fill-box; transform-origin: center; }
.seal-outer    { transform: rotate(var(--ang, 0deg)) scale(var(--sep, 1)); }
.seal-geometry { transform: rotate(calc(var(--ang, 0deg) * -0.62)) scale(var(--sep, 1)); }
.seal-core     { transform: scale(var(--sep-core, 1)); }
.is-release .seal-outer,
.is-release .seal-geometry,
.is-release .seal-core { opacity: 0; transition: opacity 1.1s var(--ease); }

/* resonance — a breath while charging */
@keyframes resonate { 50% { transform: scale(1.015); } }
.is-charge .gate__seal, .is-peak .gate__seal { animation: resonate 1.6s var(--ease) infinite; }

/* sparks orbiting the rings (SMIL motion paths in markup) */
.gate__seal .spark { fill: var(--ember); opacity: 0; transition: opacity .9s var(--ease); }
.is-spark .spark--slow { opacity: .9; }
.is-charge .spark--slow, .is-charge .spark--mid { opacity: .95; }
.is-peak .spark { opacity: 1; }
.is-release .spark { opacity: 0; }

.gate__word {
  font-family: var(--font-d);
  font-size: clamp(15px, 2.4vw, 19px);
  letter-spacing: .58em;
  text-indent: .58em;
  color: var(--ivory);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1.4s var(--ease) .2s, transform 1.4s var(--ease) .2s;
  white-space: nowrap;
}
.is-charge .gate__word, .is-peak .gate__word { opacity: .92; transform: none; }
.is-release .gate__word { opacity: 0; transition-delay: 0s; }

.gate__skip {
  position: absolute;
  bottom: 34px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .3em;
  color: var(--stone-mute);
  opacity: 0;
  transition: opacity 1s var(--ease) 1.6s;
}
.is-spark .gate__skip, .is-charge .gate__skip { opacity: .6; }
.is-peak .gate__skip, .is-release .gate__skip { opacity: 0; }

/* ---------- destination choice ---------- */
.gate__choice {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1180px;
  padding: clamp(96px, 12vh, 140px) clamp(24px, 5vw, 64px) clamp(72px, 10vh, 120px);
  text-align: center;
}
.gate__kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4em;
  color: var(--bronze-lit);
  margin-bottom: 14px;
}
.gate__title {
  font-size: clamp(30px, 4.6vw, 52px);
  line-height: 1.1;
  margin-bottom: clamp(48px, 8vh, 84px);
}

.wings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));   /* truly equal columns — content can't widen one */
  gap: clamp(14px, 1.8vw, 26px);
}
.wing {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: clamp(44px, 6vh, 72px) clamp(20px, 2.5vw, 40px) clamp(36px, 5vh, 56px);
  min-height: clamp(340px, 52vh, 460px);
  border: 1px solid var(--line-soft);
  background: linear-gradient(178deg, rgba(28, 31, 35, .55), rgba(16, 17, 19, 0) 70%);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  text-decoration: none;
  color: var(--marble);
  transition: border-color .6s var(--ease), background .6s var(--ease), transform .6s var(--ease);
}
.wing::before {
  /* the lintel — a doorway line above each wing */
  content: "";
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 56px; height: 1px;
  background: var(--bronze);
  transition: width .6s var(--ease);
}
.wing:hover, .wing:focus-visible {
  border-color: rgba(140, 115, 81, .5);
  transform: translateY(-6px);
}
.wing:hover::before, .wing:focus-visible::before { width: 96px; }
.wing__num {
  font-family: var(--font-d);
  font-size: 15px;
  letter-spacing: .26em;
  text-indent: .26em;
  color: var(--bronze-lit);
}
.wing__glyph {
  width: 64px; height: 64px;
  color: var(--bronze);
  opacity: .85;
  margin: clamp(8px, 2vh, 22px) 0;
  transition: opacity .5s, filter .5s;
}
.wing:hover .wing__glyph { opacity: 1; filter: drop-shadow(0 0 14px rgba(216,201,168,.25)); }
.wing h2 {
  font-size: clamp(22px, 2.1vw, 30px);
  letter-spacing: .02em;
}
.wing p {
  font-size: 13px;
  color: var(--stone-mute);
  max-width: 26ch;
  flex-grow: 1;
}
.wing__enter {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .28em;
  text-indent: .28em;
  color: var(--ivory);
  border: 1px solid var(--line);
  padding: 12px 26px;
  transition: border-color .4s, color .4s;
  white-space: nowrap;
}
.wing:hover .wing__enter { border-color: var(--bronze); color: var(--bronze-lit); }
.wing__soon {
  position: absolute;
  top: 18px; right: 18px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .22em;
  color: var(--stone-mute);
  border: 1px solid var(--line-soft);
  padding: 5px 10px;
}

/* a wing not yet open — present but locked; no navigation, muted accents */
.wing--locked { cursor: default; opacity: .82; }
.wing--locked:hover { transform: none; border-color: var(--line-soft); }
.wing--locked:hover::before { width: 56px; }
.wing--locked:hover .wing__glyph { opacity: .85; filter: none; }
.wing--locked .wing__num,
.wing--locked .wing__glyph { color: var(--stone-mute); }
.wing__enter--soon,
.wing--locked:hover .wing__enter--soon {
  color: var(--stone-mute);
  border-color: var(--line-soft);
}

/* choice reveal — kicker & title rise gently from the receding light */
.gate__choice .rise {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
  transition-delay: var(--d, 0s);
}
.gate__choice.is-in .rise { opacity: 1; transform: none; }

/* the wings do not fade in — each doorway is struck open top-down, in
   sequence, as the activation light sweeps across. "Unlocked," not "appeared". */
.gate__choice .wing {
  opacity: 0;
  clip-path: inset(0 0 100% 0);
}
.gate__choice.is-in .wing {
  animation: doorway 1.05s var(--ease) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes doorway {
  0%   { opacity: 0; clip-path: inset(0 0 100% 0); }
  30%  { opacity: 1; }
  100% { opacity: 1; clip-path: inset(0 0 0% 0); }
}

/* ---------- departure: spatial passage into a wing ---------- */
.gate__wash {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: radial-gradient(circle at var(--wx, 50%) var(--wy, 50%), rgba(216, 201, 168, .92), rgba(140, 115, 81, .65) 30%, var(--graphite) 72%);
  opacity: 0;
  transition: opacity .85s var(--ease);
}
body.is-departing .gate__wash { opacity: 1; }
body.is-departing .gate__choice {
  transform: scale(1.12);
  filter: blur(3px);
  opacity: .4;
  transition: transform .9s var(--ease), filter .9s var(--ease), opacity .9s var(--ease);
}
body.is-departing .wing--chosen {
  transform: translateY(-6px) scale(1.06);
  border-color: var(--bronze);
}

/* arrival veil: wings fade from the gateway light */
.arrive-veil {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(216, 201, 168, .82), rgba(140, 115, 81, .4) 34%, var(--graphite) 72%);
  opacity: 1;
  animation: arrive 1s var(--ease) forwards;
}
@keyframes arrive { to { opacity: 0; } }

/* ---------- spatial departure on every internal navigation (transition.js) ----------
   The light wash blooms from the clicked link and the page recedes — the same
   passage as the gateway, so moving between wings/tabs reads as one world. */
.page-wash {
  position: fixed; inset: 0; z-index: 90; pointer-events: none;
  background: radial-gradient(circle at var(--wx, 50%) var(--wy, 50%), rgba(216, 201, 168, .92), rgba(140, 115, 81, .6) 28%, var(--graphite) 72%);
  opacity: 0;
  transition: opacity .72s var(--ease);
}
body.is-leaving .page-wash { opacity: 1; }
body.is-leaving .wingpage,
body.is-leaving .hall,
body.is-leaving .station {
  transition: transform .8s var(--ease), filter .8s var(--ease), opacity .8s var(--ease);
  transform: scale(1.05);
  filter: blur(3px);
  opacity: .4;
}
/* the chosen card leans forward as the page recedes into the light (cf. .wing--chosen) */
.is-chosen {
  transition: transform .8s var(--ease), border-color .8s var(--ease);
  transform: translateY(-6px) scale(1.04);
  border-color: var(--bronze);
}

.gate__foot {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 22px clamp(24px, 5vw, 64px);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .24em;
  color: var(--stone-mute);
}

/* ---------- ceremonial backdrop: a monumental imperial silhouette ----------
   Abstract dark-renaissance architecture (temple · statue · obelisk · arcade)
   in graphite with a bronze break of light. Behind the choice; reveals with it. */
.gate__scene {
  position: absolute; inset: 0;
  z-index: 1;                 /* behind the choice (z-index 2), above the gate bg */
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 2.6s var(--ease) .3s;
}
.gate__stage.is-open ~ .gate__scene { opacity: 1; }
.gate__sky {
  position: absolute; inset: 0;
  background:
    linear-gradient(to top, rgba(16, 17, 19, 0) 34%, rgba(20, 22, 26, .45) 72%, rgba(11, 12, 14, .85) 100%),
    radial-gradient(ellipse 64% 42% at 52% 24%, rgba(140, 115, 81, .10), transparent 62%);
  animation: gate-sky 42s ease-in-out infinite alternate;
}
.gate__break {
  position: absolute; left: 52%; top: 20%;
  width: 78vmax; height: 56vmax;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(216, 201, 168, .15), rgba(140, 115, 81, .07) 32%, transparent 62%);
  animation: gate-breath 9s ease-in-out infinite;
}
.gate__arch {
  position: absolute; bottom: 0; left: 0;
  width: 100%; height: 84%;
  opacity: .66;
}
.gate__ember {
  position: absolute; bottom: 13%;
  left: calc(22% + var(--i) * 27%);
  width: 2px; height: 2px; border-radius: 50%;
  background: var(--ember);
  opacity: 0;
  animation: gate-ember 12s linear infinite;
  animation-delay: calc(var(--i) * 3.6s);
}
@keyframes gate-sky   { from { transform: translateX(-1.8%); } to { transform: translateX(1.8%); } }
@keyframes gate-breath { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes gate-ember {
  0%   { opacity: 0;   transform: translateY(0); }
  12%  { opacity: .55; }
  82%  { opacity: .15; }
  100% { opacity: 0;   transform: translateY(-44vh); }
}

/* ============================================================
   WING ENVIRONMENTS (calculator · journal)
   ============================================================ */
.wingpage {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
.wingpage--measure {
  background:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(116, 134, 152, .07), transparent 60%),
    var(--graphite);
}
.wingpage--archive {
  background:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(140, 115, 81, .08), transparent 60%),
    var(--graphite);
}

.wingpage__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(24px, 5vw, 64px);
}
.wingpage__nav a {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .26em;
  color: var(--stone-mute);
  text-decoration: none;
  transition: color .4s;
}
.wingpage__nav a:hover { color: var(--ivory); }
/* unified brand mark — the seal glyph + wordmark, identical to Academy's nav */
.wingpage__brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.wingpage__brand svg { width: 32px; height: 32px; color: var(--bronze); flex: none; }
.wingpage__brand span {
  font-family: var(--font-d);
  font-size: 19px;
  letter-spacing: .4em;
  text-indent: .4em;
  text-transform: none;
  color: var(--ivory);
}

.wingpage__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(72px, 10vh, 120px) 24px;
}
.wingpage__glyph { width: 76px; height: 76px; color: var(--bronze); opacity: .9; margin-bottom: 34px; }
.wingpage__kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .38em;
  color: var(--bronze-lit);
  margin-bottom: 22px;
}
.wingpage__title { font-size: clamp(40px, 7vw, 76px); line-height: 1.05; margin-bottom: 26px; }
.wingpage__lead { max-width: 520px; font-size: 15.5px; color: var(--marble); margin-bottom: 46px; }

.wingpage__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 54px;
  min-width: min(420px, 86vw);
  border-top: 1px solid var(--line-soft);
}
.wingpage__list li {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 15px 4px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
  color: var(--marble);
}
.wingpage__list li span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .2em;
  color: var(--stone-mute);
  align-self: center;
  white-space: nowrap;
}

.wingpage__actions { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.btn {
  display: inline-block;
  font-family: var(--font-b);
  font-size: 11.5px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .24em;
  text-indent: .24em;
  text-decoration: none;
  padding: 16px 36px;
  border: 1px solid;
  cursor: pointer;
  transition: background .5s var(--ease), border-color .5s var(--ease), color .5s var(--ease);
  text-align: center;
}
.btn--primary { color: var(--graphite); background: var(--ivory); border-color: var(--ivory); }
.btn--primary:hover { background: var(--bronze); border-color: var(--bronze); color: var(--ivory); }
.btn--ghost { color: var(--marble); background: transparent; border-color: var(--line); }
.btn--ghost:hover { border-color: var(--bronze); color: var(--ivory); }

.wingpage__foot {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 24px clamp(24px, 5vw, 64px);
  border-top: 1px solid var(--line-soft);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .24em;
  color: var(--stone-mute);
}

/* ---------- Telegram links (public channel + premium access) ---------- */
.tg-links { display: inline-flex; align-items: center; gap: clamp(16px, 2vw, 28px); flex-wrap: wrap; }
.tg-links a {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .22em;
  color: var(--stone-mute); text-decoration: none; white-space: nowrap;
  transition: color .4s var(--ease);
}
.tg-links a:hover { color: var(--ivory); }
.tg-links a svg { width: 13px; height: 13px; flex: none; opacity: .8; transition: opacity .4s; }
.tg-links a:hover svg { opacity: 1; }
.tg-links .is-premium { color: var(--bronze-lit); }
.tg-links .is-premium:hover { color: var(--bronze); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 901px) and (max-width: 1200px) {
  .wings { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 760px; margin: 0 auto; }
}
@media (max-width: 900px) {
  .wings { grid-template-columns: 1fr; max-width: 440px; margin: 0 auto; }
  /* compact cards on phones — ~2.5 fit a screen instead of ~1.5 */
  .wing { min-height: 0; gap: 12px; padding: 26px 22px 24px; }
  .wing__num { font-size: 14px; }
  .wing__glyph { width: 44px; height: 44px; margin: 4px 0; }
  .wing p { flex-grow: 0; font-size: 13.5px; }
  /* reserve room for the wrapped foot so it never overlaps the last card */
  .gate__choice { padding-top: 76px; padding-bottom: 232px; }
  .gate__foot { position: absolute; justify-content: center; text-align: center; }
  /* footers read centred on phones, never left-ragged */
  .wingpage__foot { justify-content: center; text-align: center; }
  /* comfortable tap targets for the small footer links */
  .tg-links { gap: 12px 22px; }
  .tg-links a { padding: 11px 4px; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .gate__stage { display: none; }
  .gate__embers, .gate__flare { display: none; }
  .gate__choice .rise { opacity: 1; transform: none; transition: none; }
  .gate__choice .wing { opacity: 1; clip-path: none; animation: none; }
  .is-charge .gate__seal, .is-peak .gate__seal { animation: none; }
  .arrive-veil { animation: none; opacity: 0; }
  .gate__wash { transition: none; }
  .gate__scene { transition: none; }
  .gate__sky, .gate__break, .gate__ember { animation: none; }
  .gate__break { opacity: .6; }
}
