/* ZNE Literature Aquarium */

.zne-aq {
  position: relative;
  width: 100%;
  overflow: hidden;
  isolation: isolate;
  contain: layout paint;
  background: transparent;
  pointer-events: none;
  user-select: none;
}

.zne-aq canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  pointer-events: none;
  visibility: hidden;
}

/* Prevent a system-font flash: reveal the canvas only after the selected
 * Google Font is available and the terms have been remeasured with it. */
.zne-aq.zne-aq-font-ready canvas {
  visibility: visible;
}

/*
 * Fixed-background integration.
 * JavaScript moves a fixed aquarium directly under <body>, adds the active
 * classes below, and marks ordinary top-level site wrappers as foreground
 * layers. The aquarium therefore stays above the page background but behind
 * headers, navigation, text, buttons, media, and other website elements.
 */
html.zne-aq-background-active,
body.zne-aq-background-active {
  min-height: 100%;
}

body.zne-aq-background-active {
  position: relative;
  isolation: isolate;
}

body.zne-aq-background-active > .zne-aq--fixed {
  z-index: 0;
}

body.zne-aq-background-active > .zne-aq-foreground-layer {
  position: relative;
  z-index: 1;
}

body.zne-aq-background-active > .zne-aq-foreground-z {
  z-index: 1;
}

/*
 * Viewport-flow mode uses a centered 120% overscan area. This mode is
 * available explicitly with mode="fullscreen" but is not the default.
 */
.zne-aq--fullscreen {
  width: var(--zne-aq-viewport-width, 120dvw);
  height: var(--zne-aq-viewport-height, 120dvh);
  min-height: 120svh;
  max-width: none;
  margin-left: var(--zne-aq-viewport-offset-x, -10dvw);
  margin-right: var(--zne-aq-viewport-offset-x, -10dvw);
  margin-top: var(--zne-aq-viewport-offset-y, -10dvh);
  margin-bottom: var(--zne-aq-viewport-offset-y, -10dvh);
}

/* Default fixed background layer with the same centered 120% overscan. */
.zne-aq--fixed {
  position: fixed;
  left: var(--zne-aq-viewport-offset-x, -10dvw);
  top: var(--zne-aq-viewport-offset-y, -10dvh);
  width: var(--zne-aq-viewport-width, 120dvw);
  height: var(--zne-aq-viewport-height, 120dvh);
  min-height: 120svh;
  max-width: none;
  margin: 0;
  z-index: 0;
  pointer-events: none;
}

/* Inline mode remains available only when explicitly requested. */
.zne-aq--inline {
  height: 600px;
}

@supports not (height: 100dvh) {
  .zne-aq--fullscreen,
  .zne-aq--fixed {
    width: 120vw;
    height: 120vh;
  }

  .zne-aq--fullscreen {
    margin-left: -10vw;
    margin-right: -10vw;
    margin-top: -10vh;
    margin-bottom: -10vh;
  }

  .zne-aq--fixed {
    left: -10vw;
    top: -10vh;
  }
}

/*
 * Marked-element mode for Divi and other builders.
 * The section aquarium is hidden until JavaScript finds the marked target. This
 * fail-safe prevents a misplaced shortcode from creating a zero-height module
 * or appearing below the bottom of the page.
 */
.zne-aq--section {
  display: none;
}

.zne-aq-section-host {
  position: relative;
  isolation: isolate;
  overflow: hidden !important;
  overflow: clip !important;
}

.zne-aq-section-host > .zne-aq--section.zne-aq-section-ready {
  display: block;
  position: absolute;
  width: 120%;
  height: 120%;
  min-height: 0;
  max-width: none;
  margin: 0;
  z-index: 1;
  pointer-events: none;
}

/* Divi rows, columns, and modules inside the marked target remain above it. */
.zne-aq-section-host > .zne-aq-section-foreground-layer,
.zne-aq-section-host > .zne-aq-section-foreground-z {
  position: relative !important;
  z-index: 2 !important;
}

/* Missing targets stay invisible rather than dropping to the page bottom. */
.zne-aq--section.zne-aq-section-target-missing {
  display: none !important;
}

/*
 * Hidden game. While the board is open the aquarium layer rises above the
 * page and takes the clicks (three clicks outside the board return to the
 * aquarium), so nothing on the page underneath is pressed by accident.
 */
.zne-aq.zne-aq--playing,
body.zne-aq-background-active > .zne-aq--fixed.zne-aq--playing {
  z-index: 2147483000 !important;
  pointer-events: auto;
  touch-action: none;
}

/* Four plain line icons: left, right | down, turn. Placed by the script in
   the free strip under the board, clear of Safari's bottom bar. */
.zne-aq-keypad {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2147483001;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.zne-aq-key {
  width: 56px;
  height: 56px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.zne-aq-key:active {
  color: #000;
  background: rgba(0, 0, 0, 0.05);
}

@media (max-width: 360px) {
  .zne-aq-key { width: 52px; height: 52px; }
}

/* Sideways screens: left and right at the left edge, down and turn at the right. */
.zne-aq-keypad--split {
  justify-content: flex-start;
  gap: 4px;
}
.zne-aq-keypad--split .zne-aq-key:nth-child(2) {
  margin-right: auto;
}

.zne-aq-key svg {
  display: block;
  pointer-events: none;
}

/*
 * Landing section: [zne_aquarium_landing]
 * Phones and other tall screens: one centred column (logo, slogan, portal).
 * Wide screens: brand and portal side by side, both vertically centred.
 * The whole section fades away while the hidden game is open.
 */
.zne-landing {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 7vh, 96px) clamp(20px, 5vw, 72px);
  /* Returning: as slowly as the fish swim back. */
  transition: opacity 5s cubic-bezier(0.45, 0, 0.55, 1), visibility 0s linear 0s;
}

.zne-landing__inner {
  width: 100%;
  max-width: 1120px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-items: center;
  gap: clamp(22px, 5vh, 56px);
}

.zne-landing__brand {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(12px, 2.2vh, 22px);
  min-width: 0;
}

.zne-landing__logo {
  display: block;
  width: clamp(150px, 46vw, 280px);
  max-width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.zne-landing__slogan {
  margin: 0;
  font-size: clamp(17px, 4.6vw, 22px);
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: #2b2b2b;
  text-wrap: balance;
}

.zne-landing__portal {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  width: min(100%, 400px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

/* Layers: fish behind the logo (aquarium canvas), the logo and slogan,
 * near fish in front of the logo (this canvas), then the login portal
 * above everything. */
.zne-landing__logo,
.zne-landing__slogan {
  position: relative;
  z-index: 1;
}

.zne-landing__fish {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  user-select: none;
}

/* Everything the login shortcode outputs shares one width and rhythm,
 * so the card and any button beneath it line up. */
.zne-landing__portal > * {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.zne-landing__portal > *:first-child { margin-top: 0 !important; }
.zne-landing__portal > *:last-child { margin-bottom: 0 !important; }

.zne-landing__portal input[type="text"],
.zne-landing__portal input[type="email"],
.zne-landing__portal input[type="password"] {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .zne-landing__inner {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 400px);
    justify-items: stretch;
    column-gap: clamp(48px, 7vw, 120px);
  }
  .zne-landing__inner--solo {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }
  .zne-landing__logo {
    width: clamp(260px, 27vw, 420px);
  }
  .zne-landing__slogan {
    font-size: clamp(20px, 1.7vw, 26px);
  }
}

/* Short landscape phones: side by side, top-aligned; the brand stays in
 * view while the portal scrolls. */
@media (max-height: 560px) and (min-aspect-ratio: 1/1) {
  .zne-landing { padding-top: 20px; padding-bottom: 20px; align-items: flex-start; }
  .zne-landing__inner {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    justify-items: stretch;
    align-items: start;
    column-gap: clamp(24px, 5vw, 56px);
  }
  .zne-landing__brand { position: sticky; top: 24px; padding-top: 8vh; }
  .zne-landing__logo { width: clamp(140px, 24vw, 220px); }
}

/* Leaving: in step with the fish swimming off. */
html.zne-aq-game-on .zne-landing {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 3.2s cubic-bezier(0.45, 0, 0.55, 1), visibility 0s linear 3.2s;
}

@media (prefers-reduced-motion: reduce) {
  .zne-landing, html.zne-aq-game-on .zne-landing { transition: none; }
}

/* Full-screen front page (templates/landing-page.php). */
html.zne-aq-takeover-root {
  background: #fff;
  overflow-x: hidden;
}

body.zne-aq-takeover {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: #fff;
  color: #111;
  overflow-x: hidden;
}

.zne-aq-takeover__main {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0;
}

/* Signed-in visitors: one quiet button into the Database. */
.zne-landing__signed-in .seigei-bokuseki-demo-link {
  margin-top: 0 !important;
}

/* The portal keeps only "Access the Seigei Database." — the "Log in"
   title stays for screen readers (the form is labelled by it) but is not shown. */
.zne-landing__portal .seigei-login-heading h2,
.zne-landing__portal #seigei-login-title {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Signed in: the button is as wide as its words. */
.zne-landing__portal > .zne-landing__signed-in {
  display: flex;
  justify-content: center;
}
.zne-landing__signed-in .seigei-bokuseki-demo-link {
  display: inline-flex !important;
  width: auto !important;
  max-width: 100%;
  padding-left: 1.6em !important;
  padding-right: 1.6em !important;
  white-space: nowrap;
}

/* The account bar and admin bar step aside while the game is open, in the
   same rhythm as the landing. */
body.zne-aq-takeover .seigei-account-nav,
body.zne-aq-takeover #wpadminbar {
  transition: opacity 5s cubic-bezier(0.45, 0, 0.55, 1), visibility 0s linear 0s;
}
html.zne-aq-game-on body.zne-aq-takeover .seigei-account-nav,
html.zne-aq-game-on body.zne-aq-takeover #wpadminbar {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 3.2s cubic-bezier(0.45, 0, 0.55, 1), visibility 0s linear 3.2s;
}
