/* ==========================================================================
   Alkando — the four modes (home).

   Four tiles in the app's mode colours. Clicking one widens it, its
   description slides up out of the tile, the other three step back, and
   the whole section cross-fades to that mode's colour. Clicking it again,
   or pressing Escape, puts everything back.

   Motion: the tile is a morph on screen, so it gets the iOS drawer curve;
   the description is an entrance, so ease-out, started a beat after the
   tile begins to open so it does not race the width change.
   ========================================================================== */

.modes {
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  position: relative;
  isolation: isolate;
  /* Clip sideways only. Vertically the floating glyphs may cross the sheet's
     edge — over the sky as the sheet slides in, and past its foot — instead
     of being sliced off along a straight line. `clip` rather than `hidden`
     on x, because `hidden` would force y to become a scroll box too. */
  overflow-x: clip;
  overflow-y: visible;
  /* Home only: rise over the pinned sky. The sky's track (home.css) holds
     it pinned for exactly this one screen. */
  z-index: 2;
  padding: clamp(80px, 12vh, 130px) 24px clamp(90px, 13vh, 140px);
  font-family: var(--ak-font-ui);
  color: var(--ak-text);
}

/* --- background: one layer per mode, cross-faded ---
   Gradients cannot be transitioned, so each mode has its own layer and only
   opacity changes. */

.modes__bgs {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.modes__bg {
  position: absolute;
  inset: 0;
  opacity: 0;
  /* Light, like the rest of the flowing background: the picked mode's
     colour, mostly white. */
  background:
    radial-gradient(120% 85% at 50% 18%,
      color-mix(in srgb, var(--a) 46%, #fff) 0%,
      color-mix(in srgb, var(--a) 22%, #fff) 60%,
      #fff 100%);
  transition: opacity 700ms ease;
}

/* A solid sheet of brand colour, clearly not the night sky it slides over,
   with a shadow along its top edge so it reads as a layer on top. */
.modes__bg--base {
  opacity: 1;
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(142, 114, 255, 0.35), transparent 70%),
    linear-gradient(180deg, var(--ak-ink-2) 0%, #241c6a 45%, var(--ak-bg) 100%);
}

main > .modes {
  margin-top: -100vh;
}

/* The shadow the sheet casts on the sky as it slides in — upward only. A
   box-shadow spread below the sheet too and drew a line where it ends. */
main > .modes::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -70px;
  height: 70px;
  pointer-events: none;
  background: linear-gradient(0deg, rgba(4, 2, 16, 0.32), transparent);
}

/* "In progress" on a mode that is still being built. */
.mode__status {
  position: absolute;
  top: 24px;
  right: 18px;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  color: #fff;
  font: 800 11px/1 var(--ak-font-ui);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.modes[data-active="classic"] .modes__bg[data-bg="classic"],
.modes[data-active="work"] .modes__bg[data-bg="work"],
.modes[data-active="game"] .modes__bg[data-bg="game"],
.modes[data-active="mix"] .modes__bg[data-bg="mix"] {
  opacity: 1;
}

/* --- heading --- */

.modes__head {
  max-width: 640px;
  margin: 0 auto clamp(34px, 5vh, 52px);
  text-align: center;
}

.modes__title {
  margin: 0;
  font: 800 clamp(2.1rem, 5vw, 3.2rem)/1.08 var(--ak-font-rounded);
  letter-spacing: -0.02em;
}

.modes__sub {
  margin: 14px 0 0;
  color: var(--ak-text-2);
  font: 400 clamp(1rem, 1.6vw, 1.15rem)/1.5 var(--ak-font-ui);
}

/* --- tiles --- */

.modes__list {
  display: flex;
  gap: 14px;
  max-width: 1180px;
  height: clamp(380px, 56vh, 470px);
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.mode {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--ak-radius-panel);
  background: linear-gradient(160deg, var(--a) 0%, var(--b) 78%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 22px 50px rgba(8, 4, 24, 0.35);
  transition:
    flex-grow 560ms var(--ease-drawer),
    filter 300ms ease,
    transform 300ms var(--ak-ease-out);
}

/* A dark floor under the text, so white reads on the pale Classic and Mix
   tints as well as on the saturated ones. */
.mode::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(0deg, rgba(10, 6, 30, 0.62) 0%, rgba(10, 6, 30, 0.12) 46%, transparent 70%);
}

.mode.is-open {
  flex-grow: 2.7;
}

/* The others step back rather than disappear: they stay one click away.
   Darkened, not made transparent — see-through tiles let the floating
   bubbles behind them show through. */
.modes.has-open .mode:not(.is-open) {
  filter: brightness(0.62) saturate(0.85);
}

@media (hover: hover) and (pointer: fine) {
  .modes.has-open .mode:not(.is-open):hover {
    filter: brightness(0.85);
  }

  .mode:not(.is-open):hover {
    transform: translateY(-4px);
  }
}

/* The whole tile is the button. */
.mode__tile {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.mode__tile:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -5px;
}

.mode__glyph {
  position: absolute;
  top: 20px;
  left: 20px;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
  color: #fff;
}

.mode__glyph svg {
  width: 23px;
  height: 23px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode__art {
  /* The mode art is drawn as a bust, deliberately cut off along its bottom
     and left edges — those cuts must never be seen. As in the app: the bust
     is mirrored so the cut side faces right, then pinned to the tile's
     bottom-right corner, so both cuts sit exactly on the tile's edges and
     the clip hides them. Nothing ever moves, scales or tilts it — any of
     that would pull a cut edge into view. Mirrored, she also looks toward
     the tile's text, which is why the app flips her when she stands on the
     right. --w sizes each file so all four heads come out the same size;
     --k scales the set per screen size. --drop sinks the taller busts
     below the tile's edge so all four faces sit on the same line. */
  --k: 1.15;
  position: absolute;
  right: 0;
  bottom: calc(var(--drop, 0px) * var(--k) * -1);
  z-index: -1;
  display: block;
  width: calc(var(--w, 220px) * var(--k));
  max-width: 100%;
  height: auto;
  transform: scaleX(-1);
}

@media (hover: hover) and (pointer: fine) {
  .mode:not(.is-open):hover .mode__glyph svg {
    animation: glyphWiggle 520ms var(--ak-ease-out);
  }
}

@keyframes glyphWiggle {
  0%, 100% { transform: none; }
  25% { transform: rotate(-14deg) scale(1.1); }
  55% { transform: rotate(10deg) scale(1.06); }
  80% { transform: rotate(-4deg); }
}

.mode__name {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  z-index: 2;
  font: 800 clamp(1.3rem, 2.1vw, 1.75rem)/1.1 var(--ak-font-rounded);
  letter-spacing: -0.015em;
  text-shadow: 0 2px 14px rgba(8, 4, 24, 0.4);
  transition: transform 560ms var(--ease-drawer);
}

/* --- what slides out of the tile --- */

.mode__more {
  position: absolute;
  left: 22px;
  bottom: 64px;
  z-index: 2;
  width: min(56%, 330px);
  pointer-events: none;
}

.mode__inner {
  opacity: 0;
  transform: translateY(18px);
  /* Closing: quick and immediate. */
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.mode.is-open .mode__more {
  pointer-events: auto;
}

.mode.is-open .mode__inner {
  opacity: 1;
  transform: none;
  /* Opening: waits for the tile to make room, then rises into it. */
  transition:
    opacity 380ms var(--ak-ease-out) 170ms,
    transform 380ms var(--ak-ease-out) 170ms;
}

.mode.is-open .mode__name {
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
}

.mode__line {
  margin: 0 0 14px;
  font: 500 clamp(1rem, 1.35vw, 1.1rem)/1.45 var(--ak-font-ui);
  text-shadow: 0 1px 10px rgba(8, 4, 24, 0.45);
}

.mode__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mode__chips li {
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font: 700 12.5px/1 var(--ak-font-ui);
  white-space: nowrap;
}

/* The chips arrive one after another, like the app's lists do. */
.mode.is-open .mode__chips li {
  animation: modeChipIn 340ms var(--ak-ease-out) both;
  animation-delay: calc(260ms + var(--c, 0) * 45ms);
}

.mode__chips li:nth-child(2) { --c: 1; }
.mode__chips li:nth-child(3) { --c: 2; }
.mode__chips li:nth-child(4) { --c: 3; }

@keyframes modeChipIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* --- phones: a column of tiles that open downwards --- */

@media (max-width: 760px) {
  .modes__list {
    flex-direction: column;
    height: auto;
  }

  .mode {
    flex: none;
    height: 124px;
    transition:
      height 520ms var(--ease-drawer),
      opacity 300ms ease;
  }

  .mode.is-open {
    height: 330px;
  }

  .mode__art {
    --k: 0.6;
  }


  .mode__glyph {
    top: 16px;
    left: 16px;
    width: 40px;
    height: 40px;
  }

  .mode__name {
    left: 18px;
    bottom: 18px;
  }

  .mode__more {
    left: 18px;
    bottom: 60px;
    width: calc(100% - 150px);
  }

  .mode__chips li {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mode,
  .mode__name {
    transition: opacity 200ms ease;
  }

  .mode__inner,
  .mode.is-open .mode__inner {
    transform: none;
    transition: opacity 200ms ease;
  }

  .mode.is-open .mode__chips li {
    animation: none;
  }
}

/* ---------------------------------------------------------------------- */
/* Floating loot                                                            */
/* ---------------------------------------------------------------------- */

/* Structured.app fills its sections with drifting bubbles; these are ours,
   carrying the app's own feature and mode glyphs. Two layers of motion that never fight:
   the outer span is moved by modes.js with the scroll (parallax, each at its
   own speed), the inner <i> bobs on a loop. Both are transform-only. */
.floats {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* The sheet's own layer covers the modes block only (heading and tiles);
   the FAQ below carries its own. Without this, the FAQ lengthening the
   sheet would stretch these percentages down behind the tiles. */
.modes > .floats {
  bottom: auto;
  height: calc(clamp(80px, 12vh, 130px) + clamp(380px, 56vh, 470px) + 220px);
}

.modes__head,
.modes__list {
  position: relative;
  z-index: 1;
}

.float {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  will-change: transform;
  /* The pointer layer: modes.js nudges `translate` toward the cursor, each
     bubble by its own depth. Separate from `transform` (scroll parallax) and
     `scale` (pop-in), so the three never overwrite each other. */
  translate: var(--mx, 0) var(--my, 0);
  transition: translate 1100ms var(--ak-ease-out);
}

.float i {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  /* Flat, like structured.app's: one solid colour, no gloss, no glow. The
     highlight and inner shadow this had made them read as plastic. */
  background: var(--c);
  transform: rotate(var(--r));
  /* Constant, looping motion: a symmetric curve both ways, never ease-in on
     its own. */
  animation: floatBob var(--d) ease-in-out infinite alternate;
}

.float--pill {
  height: calc(var(--size) * 1.55);
}

.float--pill i {
  border-radius: 999px;
}

.float svg {
  width: 44%;
  height: 44%;
  fill: none;
  stroke: #fff;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes floatBob {
  from { transform: translateY(-7px) rotate(var(--r)); }
  to { transform: translateY(7px) rotate(calc(var(--r) * -0.6)); }
}

/* On the dedicated modes page the tiles sit in the page, not in a sheet —
   no loot flying around the content there. */
.feat .floats {
  display: none;
}

@media (max-width: 760px) {
  .float {
    width: calc(var(--size) * 0.62);
    height: calc(var(--size) * 0.62);
  }

  .float--pill {
    height: calc(var(--size) * 0.62 * 1.55);
  }

  /* Half of them: on a phone the column of tiles leaves little free edge. */
  .float:nth-child(even) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .float i,
  .mode:not(.is-open):hover .mode__glyph svg {
    animation: none;
  }

  .float {
    translate: none;
  }
}
