/* ============================================================================
   The Marina Foundry
   ----------------------------------------------------------------------------
   One screen: a living pixel coastline, a mark, and a name.

   The artwork keeps all the warm light — lamp, lantern, campfire. Everything
   laid on top of it is cool and square: moonlight-blue accent, pixel type,
   scanlines, no rounded corners, nothing anti-aliased.
   ========================================================================= */

/* ---------------------------------------------------------------- tokens -- */
:root {
  --navy-900: #050813;   /* page base, deeper than the artwork */
  --navy-800: #0a1128;   /* the scene's night sky */
  --cream:    #f5efdf;   /* bitmap "paper" white */

  /* UI accent: the moonlight lying on the water, so the chrome reads cool
     and the warm light stays where it belongs — inside the artwork */
  --accent:   #7cc7ea;

  --ink-2:    rgba(245, 239, 223, .70);
  --line:     rgba(245, 239, 223, .14);

  --sans:  "Space Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --pixel: "Press Start 2P", var(--mono);

  --gut: clamp(20px, 5vw, 40px);
}

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

html, body { height: 100%; }

body {
  background: var(--navy-900);
  color: var(--cream);
  font-family: var(--sans);
  line-height: 1.65;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--accent); color: var(--navy-900); }

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
}

/* the visible heading is the artwork; this keeps a real <h1> in the document */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --------------------------------------------------------------- overlay -- */

/* film: scanlines + a whisper of grain, so the page shares the artwork's
   screen-y texture instead of looking like clean flat CSS */
.film {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: .5;
  background-image:
    repeating-linear-gradient(rgba(0, 0, 0, .16) 0 1px, transparent 1px 3px),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='.5'/></svg>");
  background-size: auto, 140px 140px;
  mix-blend-mode: overlay;
}

/* ------------------------------------------------------------------ loader --
   The scenes are multi-megabyte bitmaps, so without this the first paint is a
   bare navy rectangle for as long as the download takes. Scoped to .js: if the
   script never runs there is nothing to take the cover away again, so it must
   not appear at all. */
.js #loader {
  position: fixed;
  inset: 0;
  z-index: 200;              /* over the film (90) and the nav (100) */
  background: var(--navy-800);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity .55s ease;
}
.js #loader.gone {
  opacity: 0;
  pointer-events: none;
}

#loader i {
  width: 10px; height: 10px;
  background: var(--accent);
  animation: blink .9s steps(2, end) infinite;
}
#loader i:nth-child(2) { animation-delay: .15s; }
#loader i:nth-child(3) { animation-delay: .3s; }

@keyframes blink {
  0%, 100% { opacity: .15; }
  50%      { opacity: 1; }
}

/* -------------------------------------------------------------------- nav -- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 var(--gut);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  font-weight: 600;
  letter-spacing: -.02em;
  text-shadow: 0 2px 14px rgba(5, 8, 19, .9);
}
.brand-mark {
  width: 24px; height: 24px;
  image-rendering: pixelated;
  flex: none;
}
.brand-text { font-size: 15px; white-space: nowrap; }
.brand-text em {
  font-style: normal;
  color: var(--accent);
  margin-left: .35em;
}

/* the night / morning lamp — square, chunky, pixel-crisp */
#scene-toggle {
  flex: none;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  background: rgba(10, 17, 40, .78);
  border: 2px solid var(--line);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .4);
  cursor: pointer;
  transition: border-color .2s ease, transform .1s ease, box-shadow .1s ease;
}
#scene-toggle:hover { border-color: rgba(245, 239, 223, .55); }
#scene-toggle:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .4);
}
#scene-toggle canvas {
  width: 22px; height: 22px;
  image-rendering: pixelated;
}

/* ------------------------------------------------------------------- hero -- */
.hero {
  position: relative;
  height: 100%;
  min-height: 100svh;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  background: var(--navy-800);
  isolation: isolate;
}

/* the stage is fixed at the artwork's native size; JS translates + scales it
   to emulate background-size:cover with a focal point that protects the
   lighthouse and the campfire on narrow screens */
#stage {
  position: absolute;
  top: 0; left: 0;
  width: 2560px;
  height: 1440px;
  transform-origin: 0 0;
}

.scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  opacity: 0;
  transition: opacity .8s ease;
}
.scene.on { opacity: 1; }

/* the low-res effects canvas: 640x360 stretched over the stage and
   screen-blended, so its light adds onto the painted artwork */
#fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  mix-blend-mode: screen;
  pointer-events: none;
}

/* invisible hotspot over the fire pit */
#fire-hotspot {
  position: absolute;
  left: 57.2%;
  top: 79.4%;
  width: 9.4%;
  height: 11%;
  background: none;
  border: 0;
  cursor: pointer;
}
#fire-hotspot:focus-visible {
  outline: 4px dashed rgba(245, 239, 223, .75);
  outline-offset: 6px;
}

/* just enough shading to seat the type, without flattening the picture */
.hero-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    /* a dark strip under the nav, so the mark holds up against a bright sky */
    linear-gradient(180deg, rgba(5, 8, 19, .5) 0%, transparent 13%),
    linear-gradient(90deg, rgba(5, 8, 19, .58) 0%, rgba(5, 8, 19, .22) 38%, transparent 64%),
    linear-gradient(0deg, rgba(5, 8, 19, .88) 0%, rgba(5, 8, 19, .42) 13%, transparent 34%);
}

.hero-body {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 0 var(--gut) clamp(52px, 9vh, 96px);
}

/* the only type over the artwork: name first, then what and where.
   Given its own shadow rather than leaning on a heavy scrim. */
.hero-id {
  display: grid;
  gap: 12px;
  font-family: var(--pixel);
  text-transform: uppercase;
  text-shadow: 0 2px 16px rgba(5, 8, 19, .95), 0 0 5px rgba(5, 8, 19, .85);
}
.hero-id b {
  font-weight: 400;
  color: var(--cream);
  font-size: clamp(16px, 2.1vw, 28px);
  letter-spacing: .1em;
}
.hero-id span {
  color: var(--accent);
  font-size: clamp(9px, 1vw, 13px);
  letter-spacing: .17em;
}

/* ------------------------------------------------------------ breakpoints -- */
@media (max-width: 860px) {
  .hero-scrim {
    background:
      linear-gradient(90deg, rgba(5, 8, 19, .6) 0%, rgba(5, 8, 19, .3) 60%, rgba(5, 8, 19, .15) 100%),
      linear-gradient(0deg, rgba(5, 8, 19, .92) 0%, rgba(5, 8, 19, .5) 18%, transparent 44%);
  }
}

/* --------------------------------------------------------- accessibility -- */
@media (prefers-reduced-motion: reduce) {
  .scene { transition: none; }
  #loader i { animation: none; opacity: .75; }
}
