/* ---------- Self-hosted typefaces (no third-party requests) ---------- */

@font-face {
  font-family: 'DSEG7 Classic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/DSEG7Classic-Bold.woff2') format('woff2');
}

@font-face {
  font-family: 'DSEG14 Classic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/DSEG14Classic-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/DMSans-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/DMSans-Medium.woff2') format('woff2');
}

@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/DMSans-Bold.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/Inter-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/Inter-Medium.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/Inter-SemiBold.woff2') format('woff2');
}

@font-face {
  font-family: 'Silkscreen';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/Silkscreen-Regular.woff2') format('woff2');
}

:root {
  --tank-glow-cyan: #34C8E0;
  --bondi-blue: #0095B6;
  --aqua-gel: #7EC6E8;
  --deep-trench: #0A2540;
  --pearl-white: #F4F8FB;
  --chrome-silver-light: #E8EFF4;
  --chrome-silver-dark: #C0C8D0;
  --ink: #243B53;
  --ink-soft: #486581;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh; /* iOS Safari: dvh tracks URL-bar show/hide; vh is the fallback */
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--deep-trench);
  background: linear-gradient(
    180deg,
    var(--tank-glow-cyan) 0%,
    var(--aqua-gel) 22%,
    var(--bondi-blue) 60%,
    var(--deep-trench) 100%
  );
  position: relative;
}

/* ---------- Tank background layers ---------- */

/* Time-of-day color shift (brand rules §05). Sits between bubbles
   and the clock well, so the tank base + caustics + bubbles are tinted
   but the clock display stays clean. JS sets background-color based on
   local time; CSS transitions smooth out the per-minute updates. */
.tod-overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background-color: transparent;
  transition: background-color 6s linear;
}

.caustics {
  position: fixed;
  /* Oversized by 80px on each side so the layer's edges stay off-screen
     while it drifts via translate(-40px, 24px); prevents the caustic boundary
     from sliding into view from the top/right during the animation. */
  inset: -80px;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse 700px 320px at 18% 8%,  rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 70%),
    radial-gradient(ellipse 500px 240px at 78% 16%, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 70%),
    radial-gradient(ellipse 420px 200px at 50% 30%, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 70%);
  animation: caustics-drift 22s ease-in-out infinite alternate;
}

@keyframes caustics-drift {
  0%   { transform: translate(0, 0); }
  100% { transform: translate(-40px, 24px); }
}

.bubbles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.bubble {
  position: absolute;
  bottom: -24px;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%,
    rgba(255,255,255,0.95) 0%,
    rgba(255,255,255,0.30) 55%,
    rgba(255,255,255,0)    100%);
  animation: rise var(--d) linear infinite;
  animation-delay: var(--delay);
}

@keyframes rise {
  0%   { transform: translateY(0); opacity: 0; }
  8%   { opacity: 0.9; }
  92%  { opacity: 0.9; }
  100% { transform: translateY(-110vh); opacity: 0; }
}

/* ---------- Fish layer (autonomous Bezier-ish drift per brand rules §08) ---------- */

.fish-layer {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.fish {
  position: absolute;
  height: auto;
  left: -50vw; /* off-screen by default; JS starts each fish on a random delay */
  top: 0;
  filter: drop-shadow(0 6px 12px rgba(10, 37, 64, 0.28));
  will-change: transform, left;
}

/* Per-species size only — top, speed, direction are randomized per cycle by JS.
   drift-l2r and drift-r2l keyframes (below) handle horizontal travel + bob;
   r2l flips via scaleX(-1) so fish faces direction of travel. */
.fish-1 { width: clamp(70px,  8vw,   110px); } /* clownfish */
.fish-2 { width: clamp(80px,  9vw,   125px); } /* tangfish */
.fish-3 { width: clamp(75px,  8.5vw, 115px); } /* butterfly */
.fish-4 { width: clamp(80px,  9vw,   125px); } /* lionfish */
.fish-5 { width: clamp(75px,  8vw,   110px); } /* moorish idol */

@keyframes drift-l2r {
  0%   { left: -10%; transform: translateY(0); }
  25%  { transform: translateY(10px); }
  50%  { transform: translateY(0); }
  75%  { transform: translateY(-8px); }
  100% { left: 110%; transform: translateY(0); }
}

@keyframes drift-r2l {
  0%   { left: 110%; transform: translateY(0) scaleX(-1); }
  25%  { transform: translateY(-9px) scaleX(-1); }
  50%  { transform: translateY(0) scaleX(-1); }
  75%  { transform: translateY(8px) scaleX(-1); }
  100% { left: -10%; transform: translateY(0) scaleX(-1); }
}

/* ---------- Brand ident (top-left channel ident) ---------- */

.brand-ident {
  position: fixed;
  top: 1.75rem;
  left: 1.75rem;
  z-index: 10;
  user-select: none;
}

.brand-ident .wordmark {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--tank-glow-cyan);
  text-shadow:
    0 0 6px  rgba(52, 200, 224, 0.8),
    0 0 16px rgba(52, 200, 224, 0.45),
    0 0 32px rgba(52, 200, 224, 0.25);
}

/* ---------- Dock (Aqua-style action bar) ---------- */

.dock {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(192, 200, 208, 0.45) 100%);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 8px 24px rgba(10, 37, 64, 0.35),
    0 2px 6px rgba(10, 37, 64, 0.15);
}

.dock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: linear-gradient(180deg, #FFFFFF 0%, var(--chrome-silver-light) 55%, var(--chrome-silver-dark) 100%);
  border: 1px solid rgba(192, 200, 208, 0.9);
  border-radius: 50%;
  color: var(--deep-trench);
  cursor: pointer;
  text-decoration: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.14s ease, box-shadow 0.15s ease;
}

.dock-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 4px 12px rgba(52, 200, 224, 0.5);
}

.dock-btn:active {
  transform: scale(0.95);
}

.dock-icon {
  font-family: 'DM Sans', sans-serif;
  font-style: italic;
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--bondi-blue);
}

.dock-btn svg {
  width: 18px;
  height: 18px;
}

/* ---------- Window (Aqua-style draggable popup) ---------- */

.window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  width: min(28rem, calc(100vw - 2rem));
  background: linear-gradient(180deg, #FBFDFE 0%, var(--pearl-white) 100%);
  border: 1px solid var(--chrome-silver-dark);
  border-radius: 12px;
  box-shadow:
    0 30px 80px rgba(10, 37, 64, 0.55),
    0 8px 22px rgba(10, 37, 64, 0.25);
  overflow: hidden;
}

.window-titlebar {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0.45rem 0.7rem;
  background: linear-gradient(180deg, var(--chrome-silver-light) 0%, var(--chrome-silver-dark) 100%);
  border-bottom: 1px solid var(--chrome-silver-dark);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.window-titlebar:active {
  cursor: grabbing;
}

.window-close {
  width: 12px;
  height: 12px;
  padding: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #FF8585 0%, #DC2F2F 65%, #B81C1C 100%);
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: filter 0.12s ease;
}

.window-close:hover {
  filter: brightness(1.15);
}

.window-close:active {
  filter: brightness(0.9);
}

.window-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--deep-trench);
  pointer-events: none;
}

.window-body {
  padding: 1.75rem 1.85rem;
}

.window-h1 {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 1.4rem;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: var(--deep-trench);
}

.window-h2 {
  margin-top: 0.4rem;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.window-desc {
  margin: 1.25rem 0 0;
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink);
}

.window-meta {
  margin: 1.5rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--chrome-silver-light);
  font-family: 'Inter', sans-serif;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-align: center;
}

.window-meta a {
  color: inherit;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.window-meta a:hover {
  color: var(--bondi-blue);
  border-bottom-color: var(--aqua-gel);
}

.window-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.aqua-btn {
  padding: 0.45rem 1.1rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--deep-trench);
  background: linear-gradient(180deg, #FFFFFF 0%, var(--chrome-silver-light) 55%, var(--chrome-silver-dark) 100%);
  border: 1px solid rgba(192, 200, 208, 0.9);
  border-radius: 8px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.12s ease;
}

.aqua-btn:hover {
  filter: brightness(1.04);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 2px 6px rgba(10, 37, 64, 0.18);
}

.aqua-btn:active {
  transform: scale(0.97);
}

.aqua-btn-primary {
  color: var(--pearl-white);
  background: linear-gradient(180deg, #7EC6E8 0%, var(--bondi-blue) 100%);
  border-color: rgba(0, 84, 105, 0.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  text-shadow: 0 1px 1px rgba(10, 37, 64, 0.3);
}

/* ---------- Clock (DSEG7 LCD readout, free-floating over the tank) ---------- */

.clock-well {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
}

.clock {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
  font-family: 'DSEG7 Classic', 'Courier New', monospace;
  font-size: clamp(2.5rem, 11vw, 7rem);
  line-height: 1;
  color: var(--tank-glow-cyan);
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  text-shadow:
    0 0 14px rgba(52, 200, 224, 0.75),
    0 0 36px rgba(52, 200, 224, 0.45),
    0 0 80px rgba(52, 200, 224, 0.25);
}

.clock-analog {
  display: none;
  width: clamp(10rem, 22vw, 16rem);
  height: clamp(10rem, 22vw, 16rem);
  color: var(--tank-glow-cyan);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  filter:
    drop-shadow(0 0 10px rgba(52, 200, 224, 0.55))
    drop-shadow(0 0 24px rgba(52, 200, 224, 0.25));
}

.clock-well.analog .clock {
  display: none;
}

.clock-well.analog .clock-analog {
  display: block;
  margin: 0 auto;
}

.clock .meridiem {
  font-family: 'DSEG14 Classic', 'Courier New', monospace;
  font-size: 0.3em;
  margin-left: 0.4em;
  letter-spacing: 0.05em;
}

.clock .sep {
  display: inline-block;
  padding: 0 0.04em;
  animation: colon-pulse 2.6s ease-in-out infinite;
}

@keyframes colon-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ---------- Mobile ---------- */

@media (max-width: 620px) {
  .brand-ident {
    top: 1.25rem;
    left: 1.25rem;
  }

  .brand-ident .wordmark { font-size: 1.15rem; }

  .dock {
    bottom: 1.75rem;
    gap: 0.3rem;
    padding: 0.3rem;
  }

  .dock-btn {
    width: 36px;
    height: 36px;
  }

  .dock-btn svg { width: 16px; height: 16px; }
  .dock-icon { font-size: 1.05rem; }

  .window-body { padding: 1.4rem 1.5rem; }
  .window-h1 { font-size: 1.2rem; }
  .window-h2 { font-size: 0.9rem; }
  .window-desc { font-size: 0.85rem; }
}

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  .caustics,
  .clock .sep,
  .fish {
    animation: none;
  }

  .bubble {
    animation: none;
    opacity: 0;
  }
}
