/* ---------- Tokens ---------- */
:root {
  --bg: #1b262b;                        /* shown while the photo loads */
  --bg-dim: rgba(20, 30, 34, 0.35);     /* darkens the photo for readability */

  --text: #e6ece9;
  --muted: #b4c2bd;
  --text-shadow: 0 2px 24px rgba(5, 12, 15, 0.45);

  --glass: rgba(22, 32, 36, 0.3);
  --glass-hover: rgba(22, 32, 36, 0.4);
  --glass-edge: rgba(226, 234, 231, 0.16);
  --glass-edge-hover: rgba(226, 234, 231, 0.3);
  --glass-highlight: rgba(255, 255, 255, 0.1);
  --shadow: rgba(5, 12, 15, 0.5);
  --focus: #a9d1c5;
  --grain-opacity: 0.14;

  --logo-invert: 1;                     /* 1 = white logos, 0 = black logos */

  --font: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #dfe6e3;
    --bg-dim: rgba(230, 236, 233, 0.2);

    --text: #1b262b;
    --muted: #3d4d47;
    --text-shadow: 0 2px 24px rgba(255, 255, 255, 0.5);

    --glass: rgba(255, 255, 255, 0.45);
    --glass-hover: rgba(255, 255, 255, 0.6);
    --glass-edge: rgba(255, 255, 255, 0.6);
    --glass-edge-hover: rgba(255, 255, 255, 0.9);
    --glass-highlight: rgba(255, 255, 255, 0.5);
    --shadow: rgba(40, 60, 55, 0.3);
    --focus: #2f6b5c;
    --grain-opacity: 0.1;

    --logo-invert: 0;
  }
}

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

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Your photo, fixed behind everything (works on iOS, unlike background-attachment: fixed) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(var(--bg-dim), var(--bg-dim)),
    url("homepage_bg.jpeg") center / cover no-repeat;
}

/* Fine grain over the whole page keeps everything matte */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Layout ---------- */
/* min-height keeps name and tiles from colliding on short screens */
.stage {
  position: relative;
  min-height: 100vh;
  min-height: max(100svh, 30rem);
}

.identity,
.contacts {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
}

.identity {
  top: 30%;
  width: min(100% - 2.5rem, 40rem);
  text-align: center;
  text-shadow: var(--text-shadow);
}

.contacts {
  top: 60%;
  display: flex;
  justify-content: center;
  gap: clamp(0.9rem, 3vw, 1.5rem);
}

/* ---------- Name ---------- */
h1 {
  margin: 0;
  font-size: clamp(2.75rem, 10vw, 5.5rem);
  font-weight: 600;
  font-variation-settings: "opsz" 96;
  line-height: 1;
  letter-spacing: -0.03em;
}

.intro {
  margin: 1rem auto 0;
  max-width: 36ch;
  color: white;
  font-size: clamp(1rem, 2.4vw, 1.15rem);
}

/* ---------- Glass tiles ---------- */
.tile {
  --size: clamp(4.5rem, 16vw, 5.5rem);

  position: relative;
  display: grid;
  place-items: center;
  width: var(--size);
  aspect-ratio: 1;
  border-radius: 22px;
  color: var(--text);
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 18px 30px -18px var(--shadow);
  -webkit-backdrop-filter: blur(22px) saturate(115%);
  backdrop-filter: blur(22px) saturate(115%);

  /* entrance: tiles rise in one after another */
  animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(0.25s + var(--i, 0) * 0.09s);

  /* hover float uses `translate`, so it never fights the entrance animation */
  transition:
    translate 0.35s cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 0.35s ease,
    background-color 0.35s ease,
    border-color 0.35s ease;
}

.tile:nth-child(2) { --i: 1; }
.tile:nth-child(3) { --i: 2; }

/* Grain inside each tile */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: calc(var(--grain-opacity) * 1.6);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.tile svg,
.tile img {
  position: relative;
  width: 2rem;
  height: 2rem;
}

.tile svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile img {
  object-fit: contain;
}

/* Turns any logo into a single colour that matches the text.
   Remove class="mono" from an <img> to keep its original colours. */
.tile img.mono {
  filter: brightness(0) invert(var(--logo-invert));
  opacity: 0.92;
}

.tile:hover,
.tile:focus-visible {
  translate: 0 -8px;
  background-color: var(--glass-hover);
  border-color: var(--glass-edge-hover);
  box-shadow:
    inset 0 1px 0 var(--glass-highlight),
    0 28px 36px -20px var(--shadow);
}

.tile:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

/* Fallback when backdrop-filter isn't supported */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .tile {
    background: color-mix(in srgb, var(--bg) 80%, transparent);
  }
}

/* ---------- Footer ---------- */
.footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  text-shadow: var(--text-shadow);
}

/* ---------- Motion ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile {
    animation: none;
    transition: background-color 0.2s ease, border-color 0.2s ease;
  }
  .tile:hover,
  .tile:focus-visible {
    translate: none;
  }
}
