/* ==========================================================================
   Outside the Framework: the other side of the portfolio.
   Everything for the other reality is scoped under html[data-reality="other"],
   so normal reality is untouched. Also here: the crack, the switch, and the portal layers.
   ========================================================================== */
:root {
  --o-indigo: #0b0626;
  --o-deep: #12093a;
  --o-night: #050f16;   /* the road at night: what shows behind the world before it has drawn */
  --o-uv: #7b2cff;
  --o-mag: #73e0ff;
  --o-cyan: #2ef2ff;
  --o-acid: #b6ff2e;
  --o-orange: #ff7a1a;
  --o-ink: #f6f2ff;
  --o-ink-dim: rgba(246, 242, 255, .78);
  --o-panel: rgba(18, 9, 52, .66);
  --o-iri: linear-gradient(120deg, var(--o-cyan), var(--o-uv) 30%, var(--o-mag) 55%, var(--o-orange) 78%, var(--o-acid));
}

/* ---------- the crack (normal reality, bottom of the homepage) ---------- */
.crack-wrap { /* sits below everything at the very bottom of the work page */
  position: relative; z-index: 3; left: 58%; margin: 0 0 clamp(40px, 9vh, 96px) -60px;
  width: 120px; height: 46px;
}
/* still in the lab: hidden unless the page runs with .reality-lab (localhost or ?lab=1) */
html:not(.reality-lab) .crack-wrap { display: none; }
.crack {
  --near: 0; --open: 0;
  position: absolute; inset: 0; padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: 10px;
  transform: scale(calc(1 + var(--open) * 2.4)) rotate(calc(var(--open) * -6deg));
  transition: filter .5s ease;
  filter:
    drop-shadow(0 0 calc(1px + var(--near) * 7px + var(--open) * 30px) rgba(60, 190, 220, calc(.18 + var(--near) * .45 + var(--open) * .6)))
    drop-shadow(0 0 calc(var(--near) * 14px + var(--open) * 50px) rgba(115, 224, 255, calc(var(--near) * .35 + var(--open) * .6)));
}
.crack svg { display: block; width: 100%; height: 100%; overflow: visible; animation: crack-breathe 7s ease-in-out infinite; transform-origin: 50% 50%; }
.crack .crack-edge { fill: none; stroke: rgba(0, 0, 0, .9); stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.crack .crack-lip { fill: none; stroke: rgba(255, 255, 255, .06); stroke-width: 4.6; stroke-linecap: round; transform: translate(.6px, .9px); }
.crack .crack-light {
  fill: none; stroke: url(#crack-iris); stroke-linecap: round; stroke-linejoin: round;
  stroke-width: calc(.7px + var(--near) * 1.3px + var(--open) * 4px);
  opacity: calc(.55 + var(--near) * .45);
}
.crack:focus-visible { outline: 1px dashed rgba(115, 224, 255, .6); outline-offset: 6px; }
@keyframes crack-breathe {
  0%, 100% { transform: scale(1) skewX(0deg); }
  40% { transform: scale(1.035, .98) skewX(-1.5deg); }
  70% { transform: scale(.985, 1.02) skewX(1deg); }
}

/* ---------- the way back (other side only) ---------- */
.reality-dock {
  position: fixed; z-index: 40; left: max(16px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: center;
}
.reality-dock[hidden] { display: none; }
.reality-back, .reality-sound {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 99px; cursor: pointer;
  font: 500 13px/1 var(--sans); letter-spacing: .02em; color: #fff;
  background: rgba(8, 4, 22, .72); border: 1px solid rgba(46, 242, 255, .5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 0 0 1px rgba(115, 224, 255, .15), 0 8px 30px rgba(0, 0, 0, .4);
  transition: box-shadow .25s ease, border-color .25s ease;
}
.reality-sound { justify-content: center; width: 38px; height: 38px; padding: 0; }
.reality-sound .mute { opacity: 1; }
.reality-sound .wave { opacity: 0; transition: opacity .25s ease; }
.reality-sound[aria-pressed="true"] .mute { opacity: 0; }
.reality-sound[aria-pressed="true"] .wave { opacity: 1; }
.reality-sound[aria-pressed="true"] { border-color: var(--o-cyan, rgba(46, 242, 255, .9)); }
.reality-back:hover, .reality-back:focus-visible, .reality-sound:hover, .reality-sound:focus-visible { border-color: var(--o-mag); box-shadow: 0 0 22px rgba(115, 224, 255, .55); outline: none; }

/* ---------- the portal layers ---------- */
.portal-layer { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.portal-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.portal-leak {
  position: absolute; inset: 0; opacity: 0; mix-blend-mode: screen;
  background:
    conic-gradient(from 210deg at var(--x) var(--y), transparent 0deg, rgba(115, 224, 255, .5) 18deg, transparent 34deg,
      transparent 90deg, rgba(230, 248, 255, .42) 104deg, transparent 122deg, transparent 200deg, rgba(255, 184, 102, .3) 214deg,
      transparent 228deg, transparent 290deg, rgba(31, 143, 166, .55) 306deg, transparent 324deg),
    radial-gradient(circle at var(--x) var(--y), rgba(230, 248, 255, .5), rgba(115, 224, 255, .22) 8%, transparent 32%);
}
.portal-shards { position: absolute; inset: 0; }
.shard { position: absolute; inset: 0; overflow: hidden; background: rgba(6, 16, 24, .38); will-change: transform, opacity; }
.shard-snap { position: absolute; inset: 0; }
.shard-snap .reveal { opacity: 1 !important; transform: none !important; }
.portal-active body > :not(.portal-layer):not(.portal-skip):not(.sr-only):not(.room) { visibility: hidden; }
.portal-skip {
  position: fixed; z-index: 70; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom));
  padding: 9px 16px; border-radius: 99px; cursor: pointer;
  font: 500 13px/1 var(--sans); color: #fff;
  background: rgba(4, 16, 24, .55); border: 1px solid rgba(190, 235, 255, .35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.portal-fade { background: radial-gradient(circle at 50% 60%, #bff0ff, #1c6f86 45%, #04121c); opacity: 0; animation: portal-fade-in .25s ease forwards; }
.portal-fade.out { animation: portal-fade-out .45s ease forwards; }
@keyframes portal-fade-in { to { opacity: 1; } }
@keyframes portal-fade-out { from { opacity: 1; } to { opacity: 0; } }

/* ==========================================================================
   The other side
   ========================================================================== */
html[data-reality="other"] { color-scheme: dark; }
html[data-reality="other"] body { background: var(--o-night); color: var(--o-ink); }
.other-env {
  position: fixed; inset: 0; z-index: 0; width: 100%; height: 100%; display: block;
  opacity: 0; transition: opacity 1.2s ease;
}
.other-env.ready { opacity: 1; }
.portal-arriving .other-env { transition: none; }   /* coming through the portal, the road is simply there when the flash clears */
html:not([data-reality="other"]) .other-env { display: none; }

/* 2D world when WebGL isn't available (or fails): slow drifting colour fields */
html.other-2d[data-reality="other"] body {
  background:
    radial-gradient(40vmax 30vmax at 12% 88%, rgba(115, 224, 255, .35), transparent 70%),
    radial-gradient(36vmax 28vmax at 88% 80%, rgba(46, 242, 255, .22), transparent 70%),
    radial-gradient(50vmax 40vmax at 60% 20%, rgba(123, 44, 255, .35), transparent 70%),
    var(--o-indigo);
  background-attachment: fixed;
}

/* the crack hides on the other side; the fixed "Back to reality" pill is the way out */
html[data-reality="other"] .crack { display: none; }

/* ---- shared chrome: floating, a little off ---- */
html[data-reality="other"] .topbar::before { background: linear-gradient(rgba(11, 6, 38, .85), rgba(11, 6, 38, .4) 70%, transparent) !important; }
html[data-reality="other"] .topbar nav { animation: o-float 7s ease-in-out infinite; }
html[data-reality="other"] .topbar .mark { animation: o-float 9s ease-in-out -2s infinite; display: inline-block; }
html[data-reality="other"] .topbar nav a { color: var(--o-ink-dim); }
html[data-reality="other"] .topbar nav a:hover, html[data-reality="other"] .topbar nav a:focus-visible { color: var(--o-cyan); }
html[data-reality="other"] .lang { border-color: rgba(46, 242, 255, .4); }
html[data-reality="other"] .eyebrow { color: var(--o-acid); }
html[data-reality="other"] .btn {
  background: rgba(18, 9, 52, .55); border: 1px solid transparent;
  background-image: linear-gradient(rgba(18, 9, 52, .85), rgba(18, 9, 52, .85)), var(--o-iri);
  background-origin: border-box; background-clip: padding-box, border-box;
  color: var(--o-ink);
}
html[data-reality="other"] .btn:hover, html[data-reality="other"] .btn:focus-visible { box-shadow: 0 0 22px rgba(115, 224, 255, .5); }
@keyframes o-float {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  30% { translate: 0 -3px; rotate: -.6deg; }
  65% { translate: 0 2px; rotate: .5deg; }
}

/* ---- homepage: the forest is gone; the words are where you left them, but wrong ---- */
html[data-reality="other"] .home .scene > picture,
html[data-reality="other"] .home #forest-gl,
html[data-reality="other"] .home #leaves,
html[data-reality="other"] .home .cabin,
html[data-reality="other"] .home .vignette,
html[data-reality="other"] .home .shade,
html[data-reality="other"] .home .warmth,
html[data-reality="other"] .home .live { visibility: hidden; opacity: 0; }
html[data-reality="other"] .home .intro { z-index: 2; text-shadow: 0 2px 18px rgba(11, 6, 38, .95), 0 0 40px rgba(11, 6, 38, .7); }
html[data-reality="other"] .home .intro::before { /* a soft dark pool behind the words, so the glowing garden never fights them */
  content: ""; position: absolute; inset: -60px -80px -50px -90px; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at 40% 60%, rgba(11, 6, 38, .78), rgba(11, 6, 38, .4) 55%, transparent 75%);
}
html[data-reality="other"] .headline { animation: o-wrong 11s ease-in-out infinite; transform-origin: 20% 80%; }
html[data-reality="other"] .headline:focus { outline: none; }
html[data-reality="other"] .headline .w-exp,
html[data-reality="other"] .headline .w-design,
html[data-reality="other"] .headline .w-eng { color: #fff; text-shadow: 0 0 22px rgba(115, 224, 255, .55); }
html[data-reality="other"] .w-design .sel { border-color: var(--o-cyan); }
html[data-reality="other"] .w-design .sel i { border-color: var(--o-cyan); background: var(--o-indigo); }
html[data-reality="other"] .w-design .sel-hit::before, html[data-reality="other"] .w-design .sel-input { background: var(--o-cyan); color: var(--o-indigo); }
html[data-reality="other"] .w-eng::before { background: rgba(182, 255, 46, .14); }
html[data-reality="other"] .w-eng.typing .ch, html[data-reality="other"] .w-eng.typed .ch { color: var(--o-acid); }
@keyframes o-wrong {
  0%, 100% { transform: none; letter-spacing: -.015em; }
  25% { transform: skewY(-.6deg) translateY(-2px); letter-spacing: -.005em; }
  55% { transform: skewX(1.2deg); letter-spacing: -.022em; }
  80% { transform: skewY(.4deg) translateX(3px); }
}
html[data-reality="other"] .status { background: rgba(18, 9, 52, .55); border-color: rgba(182, 255, 46, .35); }
html[data-reality="other"] .status-dot { background: var(--o-acid); box-shadow: 0 0 10px var(--o-acid); }
html[data-reality="other"] .hint { color: var(--o-ink-dim); }
html[data-reality="other"] .scroll-cue { color: var(--o-cyan); border-color: rgba(46, 242, 255, .45); }

/* ---- the design philosophy as floating panels over the garden ---- */
html[data-reality="other"] .statement { z-index: 2; }
html[data-reality="other"] .statement .stmt {
  position: relative;
  padding: clamp(20px, 3vw, 34px) clamp(22px, 3.4vw, 40px);
  border-radius: 34px 10px 34px 10px;
  background: var(--o-panel);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: inset 0 0 0 1px rgba(46, 242, 255, .16), 0 0 0 1px rgba(115, 224, 255, .1), 0 30px 70px rgba(4, 0, 18, .55);
  color: var(--o-ink);
  animation: o-bob 9s ease-in-out infinite;
}
html[data-reality="other"] .statement .stmt:nth-child(2) { animation-delay: -3s; margin-left: clamp(0px, 4vw, 60px); border-radius: 10px 34px 10px 34px; }
html[data-reality="other"] .statement .stmt:nth-child(3) { animation-delay: -5s; margin-right: clamp(0px, 3vw, 44px); }
html[data-reality="other"] .statement .stmt:nth-child(4) { animation-delay: -7s; margin-left: clamp(0px, 2vw, 30px); border-radius: 10px 34px 10px 34px; }
@keyframes o-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -7px; } }
html[data-reality="other"] .statement .stmt::after { /* an iridescent hairline along the top edge */
  content: ""; position: absolute; left: 12%; right: 12%; top: -1px; height: 1px;
  background: var(--o-iri); opacity: .7; border-radius: 1px;
}
html[data-reality="other"] .kw-team strong { text-decoration-color: var(--o-mag); }
html[data-reality="other"] .kw .ico { border-color: rgba(46, 242, 255, .5); background: rgba(46, 242, 255, .12); }
html[data-reality="other"] .kw .ico svg { stroke: var(--o-cyan); }
html[data-reality="other"] .kw-icon:hover, html[data-reality="other"] .kw-idea:hover, html[data-reality="other"] .kw-warm:hover { color: #fff; }
html[data-reality="other"] .kw-icon:hover .ico, html[data-reality="other"] .kw-idea:hover .ico, html[data-reality="other"] .kw-warm:hover .ico {
  background: rgba(115, 224, 255, .3); border-color: var(--o-mag); box-shadow: 0 0 18px rgba(115, 224, 255, .7);
}
html[data-reality="other"] .kw-grow:hover .ch { color: var(--o-acid); }

/* ---- the work page in the city: the cabin is gone; the books are holograms beside their billboards ---- */
html[data-reality="other"] body.interior,
html[data-reality="other"] body.case { background: var(--o-night); }
html[data-reality="other"] .interior .room,
html[data-reality="other"] .case-backdrop { display: none; }
html[data-reality="other"] .interior .topbar,
html[data-reality="other"] .case .topbar { background: linear-gradient(rgba(8, 4, 22, .92), rgba(8, 4, 22, .55) 62%, transparent); }
html[data-reality="other"] .welcome h1,
html[data-reality="other"] .case-hero h1 { color: #fff; text-shadow: 0 0 34px rgba(115, 224, 255, .55), 0 2px 30px rgba(0, 0, 0, .85); }
html[data-reality="other"] .welcome .lede,
html[data-reality="other"] .welcome .back,
html[data-reality="other"] .scroll-hint,
html[data-reality="other"] .case-statement,
html[data-reality="other"] .case-overview dd { color: var(--o-ink); text-shadow: 0 1px 16px rgba(5, 2, 16, .95); }
html[data-reality="other"] .case-overview dt { color: var(--o-cyan); }

html[data-reality="other"] .project { --open: 1 !important; --shots: 1 !important; --pw: min(31vw, 390px, calc((100svh - 220px) / 1.34)); }
html[data-reality="other"] .project .cover,
html[data-reality="other"] .project .book-shadow { display: none; }
html[data-reality="other"] .project .book-body { transform: none !important; }
html[data-reality="other"] .project .stage-book { place-items: center start; padding-left: clamp(16px, 6vw, 90px); perspective: none; }
html[data-reality="other"] .project:nth-child(2) .stage-book { place-items: center end; padding-right: clamp(16px, 6vw, 90px); }
html[data-reality="other"] .project .leaf-left,
html[data-reality="other"] .project .page-right {
  background: rgba(10, 5, 32, .72);
  backdrop-filter: blur(10px) saturate(1.4); -webkit-backdrop-filter: blur(10px) saturate(1.4);
  box-shadow: inset 0 0 0 1px rgba(46, 242, 255, .35), 0 0 30px rgba(115, 224, 255, .18), 0 20px 60px rgba(0, 0, 0, .5);
  color: var(--o-ink);
}
html[data-reality="other"] .project .leaf-left { border-radius: 14px 0 0 14px; }
html[data-reality="other"] .project .page-right { border-radius: 0 14px 14px 0; }
html[data-reality="other"] .project .leaf-left::before { color: var(--o-acid); }
html[data-reality="other"] .project .leaf-left h2 { color: #fff; text-shadow: 0 0 18px rgba(46, 242, 255, .5); }
html[data-reality="other"] .project .leaf-left .meta { color: var(--o-cyan); }
html[data-reality="other"] .project .leaf-left .summary { color: var(--o-ink-dim); }
html[data-reality="other"] .project .book-link { color: #fff; border-bottom-color: var(--o-mag); }
html[data-reality="other"] .project .book-link:hover, html[data-reality="other"] .project .book-link:focus-visible { color: var(--o-cyan); }
html[data-reality="other"] .project .shot { background: #0b0620; box-shadow: 0 0 0 1px rgba(46, 242, 255, .3), 0 8px 26px rgba(0, 0, 0, .5); }
html[data-reality="other"] .project .shot::before { background: rgba(123, 44, 255, .35); }
html[data-reality="other"] .project .shot::after {
  background:
    linear-gradient(135deg, var(--o-mag), var(--o-uv)) 0 0 / 100% 52% no-repeat,
    linear-gradient(rgba(46, 242, 255, .5), rgba(46, 242, 255, .5)) 0 66% / 62% 7% no-repeat,
    linear-gradient(rgba(246, 242, 255, .25), rgba(246, 242, 255, .25)) 0 82% / 88% 7% no-repeat,
    linear-gradient(rgba(246, 242, 255, .25), rgba(246, 242, 255, .25)) 0 98% / 46% 7% no-repeat;
}
html[data-reality="other"] .interior .about,
html[data-reality="other"] .interior .credits {
  background: rgba(10, 5, 32, .7); border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(46, 242, 255, .25);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding-top: 24px; padding-bottom: 24px; color: var(--o-ink);
}
html[data-reality="other"] .interior .credits { margin-bottom: 90px; }
html[data-reality="other"] .interior .credits a { color: var(--o-cyan); }
@media (max-aspect-ratio: 1/1) {
  html[data-reality="other"] .project { --pw: min(86vw, calc((100svh - 215px) / 1.42)); }
  html[data-reality="other"] .project .stage-book,
  html[data-reality="other"] .project:nth-child(2) .stage-book { place-items: end center; padding: 0 var(--gutter) 72px; }
  html[data-reality="other"] .project .page-right { display: none; }     /* phones: the billboard is the picture */
  html[data-reality="other"] .project .leaf-left { height: auto; border-radius: 14px; padding-bottom: calc(var(--pw) * .07); }
  html[data-reality="other"] .project .book { height: auto; width: var(--pw); }
  html[data-reality="other"] .project .book-body { position: relative; inset: auto; }
  html[data-reality="other"] .project .leaf-left { position: relative; }
}

/* ---- the case study in the city: the story stays on its paper, now lit by neon ---- */
html[data-reality="other"] .case-paper { box-shadow: 0 0 0 1px rgba(46, 242, 255, .4), 0 0 60px rgba(115, 224, 255, .25), 0 30px 80px rgba(0, 0, 0, .6); }
html[data-reality="other"] .case-close .case-statement { color: #fff; }

@media (prefers-reduced-motion: reduce) {
  html[data-reality="other"] .headline,
  html[data-reality="other"] .topbar nav,
  html[data-reality="other"] .topbar .mark,
  html[data-reality="other"] .statement .stmt,
  .crack svg { animation: none; }
}

/* while the portal's tools arrive, the crack strains and charges (GSAP takes --open over from here) */
@property --open { syntax: '<number>'; inherits: true; initial-value: 0; }
.crack.splitting { --near: 1; animation: crack-charge 3s cubic-bezier(.3, 0, .2, 1) forwards; }
.crack.splitting svg { animation: crack-strain .14s steps(2, end) infinite; }
@keyframes crack-charge { to { --open: .32; } }
@keyframes crack-strain { 0% { transform: translate(.6px, -.4px) scale(1.02); } 100% { transform: translate(-.5px, .5px) scale(.99); } }
@media (prefers-reduced-motion: reduce) { .crack.splitting, .crack.splitting svg { animation: none; } }

/* the woods' live weather pill belongs to reality; the city has its own weather */
html[data-reality="other"] .live { display: none !important; }
