/* ==========================================================================
   home.css  -  the design of the homepage (index.html)
   ========================================================================== */

/* ---------- COLOUR TOKENS ---------- */

/* The logo's colours, stored in named boxes ("custom properties") on :root,
   which means "the whole page". To re-skin the logo, change these three
   values and everything below follows.
   - --ink:   the logo's normal colour
   - --ink-2: the first glow colour (pink)
   - --ink-3: the second glow colour (cyan) */
:root {
  --ink: #fff;
  --ink-2: #FF4FD8;
  --ink-3: #4FF8FF;
}

/* ---------- BASICS ---------- */

/* Makes width and height include padding and borders, so sizes behave the
   way you expect. The "*" means "every element". */
* {
  box-sizing: border-box;
}

/* Browsers add a small margin around the page by default. We remove it so
   the black background reaches every edge of the screen. */
html,
body {
  margin: 0;
  height: 100%;
}

/* Never show a sideways scrollbar, even if a logo glow pokes out a little
   further than expected. */
html {
  overflow-x: hidden;
}

body {
  background-color: #000000;   /* black background */
  color: #ffffff;              /* white text */
  /* Carlito first. If it hasn't loaded yet, use Calibri, then any plain font. */
  font-family: "Carlito", Calibri, sans-serif;

  /* Stops visitors from highlighting (selecting) text or the logo by
     clicking and dragging. The "-webkit-" line is for Safari on iPhones
     and Macs, which only understands this older spelling. */
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- THE CENTERED LAYOUT ---------- */

.home {
  /* Fill at least the whole screen height, so we can center vertically.
     "svh" is the screen height on phones excluding the browser's address
     bar. The plain "vh" line before it is a backup for older browsers. */
  min-height: 100vh;
  min-height: 100svh;

  /* Flexbox: a tool to line things up. "column" stacks the logo, text and
     button on top of each other. The two "center" lines put them in the
     middle, top-to-bottom and left-to-right. */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  /* Space between the logo, the text and the button */
  gap: 2.5rem;

  /* Breathing room so nothing touches the screen edges on phones */
  padding: 2rem 1.5rem;
  text-align: center;
}

/* ---------- 1. THE LOGO ---------- */

.home-logo {
  margin: 0;        /* <h1> has a built-in margin; we use "gap" instead */
  width: 100%;
  max-width: 900px; /* big, but not endless on very wide screens */
}

.home-logo svg {
  display: block;   /* removes a tiny gap browsers leave under drawings */
  width: 100%;      /* fill the .home-logo box... */
  height: auto;     /* ...and keep the logo's proportions (from its viewBox) */

  /* Lets the glows spill past the edges of the drawing instead of being
     cut off (by default, an SVG hides anything outside its own box). This
     only changes what is painted, not the size of the box, so nothing on
     the page moves. */
  overflow: visible;

  /* Protects the logo from being selected or saved:
     - user-select: none (plus the Safari spelling) stops highlighting.
     - pointer-events: none makes the drawing ignore the mouse and fingers
       completely, so right-click and dragging no longer reach it.
       (Safe here because the logo is not a link.)
     - -webkit-touch-callout: none hides the menu that iPhones show when
       you press and hold. */
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
  -webkit-touch-callout: none;
}

/* ---------- 1b. THE GLOW COLOURS ---------- */

/* The three glow effects live inside the SVG (in its <defs>). Their colour
   comes from "flood-color", which we point at the colour tokens above, so
   re-skinning :root also re-colours the glows. */
.fx-ink-1 { flood-color: var(--ink); }
.fx-ink-2 { flood-color: var(--ink-2); }
.fx-ink-3 { flood-color: var(--ink-3); }

/* ---------- 1c. THE LETTER ANIMATION ("VOLTAGE") ---------- */

/* Every letter (each <g class="fx-voltage-letter">) runs the same animation,
   called fx-voltage, which lasts 2.6 seconds and repeats forever. */
.fx-voltage-letter {
  fill: var(--ink);   /* the letter's normal colour */

  /* steps(1) = jump straight from one keyframe to the next, with no smooth
     in-between. That is what makes it look like electric crackles. */
  animation: fx-voltage 2.6s steps(1) infinite;

  /* Each letter waits a little longer than the one before it: its --i
     number (0 to 13, set in the HTML) times 0.08 seconds. So the flashes
     ripple from left to right. */
  animation-delay: calc(var(--i) * .08s);

  /* By default, SVG shapes tilt around the corner of the whole drawing.
     These two lines make each letter tilt around its OWN centre. */
  transform-box: fill-box;
  transform-origin: center;
}

/* The keyframes: what a letter looks like at each moment of its 2.6 s loop.
   Most of the time (11% to 48%, and 63% to 100%) it is calm and plain.
   - 7%:  a white flash with the pink glow, nudged up-right and tilted
   - 9%:  a cyan flash with the cyan glow, nudged down-left, tilted the
          other way
   - 61%: a smaller white flash with the double pink/cyan glow
   The glows use filter: url(#...) (the SVG glow effects) rather than CSS
   shortcuts like drop-shadow(), because Safari does not apply those to
   shapes inside an SVG. */
@keyframes fx-voltage {
  0%, 100% { transform: none; fill: var(--ink); filter: none; }
  7%  { transform: translate(1px, -1px) skewX(-10deg); fill: #fff; filter: url(#fx-flash-a); }
  9%  { transform: translate(-1px, 1px) skewX(8deg); fill: var(--ink-3); filter: url(#fx-flash-b); }
  11%, 48% { transform: none; fill: var(--ink); filter: none; }
  61% { transform: translate(0, -1px) skewX(4deg); fill: #fff; filter: url(#fx-flash-c); }
  63% { transform: none; fill: var(--ink); filter: none; }
}

/* ---------- 1d. THE VAPOR-TRAIL ANIMATION ---------- */

/* The page picks one of two animations at random on every load (see the
   small script in the <head> of index.html):
   - no class on <html>            = voltage (section 1c above)
   - "fx-vapor-mode" on <html>     = vapor (this section)
   In vapor mode, two blurred, coloured copies of the logo (the "ghosts")
   drift and stretch behind it like a trail, while the real logo sways
   gently from side to side with a soft white halo.
   The distances below are in the logo's own drawing units (it is 1828
   units wide), not in screen pixels, so they scale with the logo. */

/* The ghosts: hidden unless vapor mode is on.
   - transform-box + transform-origin: stretch around their own centre
   - filter: url(#fx-vapor-blur) = the SVG blur effect from <defs>
     (Safari ignores CSS blur() on shapes inside an SVG)
   - pointer-events: none = they never catch clicks or taps */
.fx-vapor-ghost {
  display: none;
  transform-box: fill-box;
  transform-origin: center;
  filter: url(#fx-vapor-blur);
  opacity: .62;
  pointer-events: none;
}

.fx-vapor-mode .fx-vapor-ghost {
  display: block;
}

/* The pink ghost and the cyan ghost: same 2.8 s rhythm, but they drift in
   opposite directions. "ease-in-out" = slow at the ends, faster in the
   middle, for a smooth floating feel (unlike voltage's sudden jumps). */
.fx-vapor-a {
  fill: var(--ink-2);
  animation: fx-vapor-a 2.8s ease-in-out infinite;
}

.fx-vapor-b {
  fill: var(--ink-3);
  animation: fx-vapor-b 2.8s ease-in-out infinite;
}

/* In vapor mode the voltage letter animation is switched off, and the whole
   main logo drifts instead, with the soft white halo (fx-vapor-glow). */
.fx-vapor-mode .fx-voltage-letter {
  animation: none;
}

.fx-vapor-mode .fx-main {
  transform-box: fill-box;
  transform-origin: center;
  filter: url(#fx-vapor-glow);
  animation: fx-vapor-main 2.8s ease-in-out infinite;
}

/* The main logo sways 6 units left, then 6 units right, and back. */
@keyframes fx-vapor-main {
  0%, 100% { transform: translateX(-6px); }
  50%      { transform: translateX(6px); }
}

/* The pink ghost trails to the left, stretching wider and getting
   stronger halfway through the loop. */
@keyframes fx-vapor-a {
  0%, 100% { transform: translate(-20px, 12px) scaleX(1.08); opacity: .1; }
  50%      { transform: translate(-36px, -8px) scaleX(1.22); opacity: .28; }
}

/* The cyan ghost mirrors it, trailing to the right. */
@keyframes fx-vapor-b {
  0%, 100% { transform: translate(20px, -10px) scaleX(1.08); opacity: .1; }
  50%      { transform: translate(36px, 10px) scaleX(1.2); opacity: .26; }
}

/* ---------- 1e. REDUCED MOTION ---------- */

/* Some visitors turn on "reduce motion" in their phone or computer settings
   (flashing and drifting can cause discomfort or headaches). For them, in
   both modes, we switch every logo animation off, hide the ghosts and drop
   the halo, so the logo stays still and plain white. */
@media (prefers-reduced-motion: reduce) {
  .fx-voltage-letter,
  .fx-vapor-ghost,
  .fx-main,
  .fx-vapor-mode .fx-main {
    animation: none;
  }

  .fx-vapor-ghost,
  .fx-vapor-mode .fx-vapor-ghost {
    display: none;
  }

  .fx-vapor-mode .fx-main {
    filter: none;
  }
}

/* ---------- 2. THE TEXT ---------- */

.home-status {
  margin: 0;
  /* clamp(smallest, preferred, largest): the text grows with the screen
     width (vw), but never below 1.25rem or above 2rem. */
  font-size: clamp(1.25rem, 3vw, 2rem);
  letter-spacing: 0.1em;  /* a little extra space between letters */
}

/* ---------- 3. THE BUTTON ---------- */

.home-button {
  display: inline-block;
  padding: 0.9rem 2.5rem;
  background-color: #000000;  /* black button (same as the page) */
  color: #ffffff;             /* white text on it */
  border: 2px solid #ffffff;  /* thin white outline around it */
  font-size: 1rem;
  font-weight: 700;           /* bold */
  letter-spacing: 0.15em;
  text-decoration: none;      /* links are underlined by default; remove it */
  /* Animate the color change on hover over 0.2 seconds */
  transition: background-color 0.2s, color 0.2s;
}

/* The button turns white with black text when:
   - :hover          the mouse is over it (computers)
   - :active         it is being pressed (phones have no mouse, so this is
                     what makes it light up under a finger)
   - :focus-visible  it is selected with the keyboard (Tab key) */
.home-button:hover,
.home-button:active,
.home-button:focus-visible {
  background-color: #ffffff;
  color: #000000;
}

/* A clear outline for keyboard users, so they can see where they are */
.home-button:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 4px;
}
