/* Festov — single viewport, no page scroll */

:root {
  --bg: #0c1210;
  --bg-elev: #131a17;
  --ink: #e7efe9;
  --ink-dim: #9aada3;
  --ink-faint: #6a7d74;
  --line: rgba(231, 239, 233, 0.12);
  --accent: #3ecf8e;
  --accent-dim: rgba(62, 207, 142, 0.14);
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "Space Grotesk", system-ui, sans-serif;
  --font-desc: "Sora", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --pad: clamp(16px, 2.6vw, 36px);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

/* ===== Atmosphere ===== */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: #0a0f0d;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  will-change: transform;
  transition: transform 0.6s var(--ease-out);
}

.orb-a {
  width: min(55vw, 620px);
  height: min(55vw, 620px);
  left: -10%;
  top: -15%;
  background: radial-gradient(circle, rgba(62, 207, 142, 0.45), transparent 65%);
  animation: pulse-orb 8s ease-in-out infinite;
}

.orb-b {
  width: min(40vw, 480px);
  height: min(40vw, 480px);
  right: -8%;
  top: 20%;
  background: radial-gradient(circle, rgba(70, 150, 180, 0.35), transparent 65%);
  animation: pulse-orb 11s ease-in-out infinite reverse;
}

.orb-c {
  width: min(45vw, 520px);
  height: min(45vw, 520px);
  left: 35%;
  bottom: -25%;
  background: radial-gradient(circle, rgba(180, 140, 70, 0.18), transparent 70%);
  animation: pulse-orb 13s ease-in-out infinite;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.28;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%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");
}

/* ===== Boot ===== */
.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #050807;
  transition: opacity 0.7s var(--ease), visibility 0.7s;
}

.boot.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-mark {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 800;
  letter-spacing: -0.06em;
  text-transform: lowercase;
  animation: boot-pulse 1.1s var(--ease) both;
}

/* ===== Chrome ===== */
.topbar,
.stage {
  position: relative;
  z-index: 1;
}

.topbar {
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 0px));
  right: max(14px, env(safe-area-inset-right, 0px));
  z-index: 40;
  display: flex;
  gap: 2px;
}

.lang-btn {
  padding: 8px 11px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 600;
}

.lang-btn.is-active,
.lang-btn:hover {
  color: var(--ink);
}

/* ===== Stage: fills viewport ===== */
.stage {
  height: 100dvh;
  height: 100svh;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.35fr);
  gap: clamp(16px, 2.5vw, 36px);
  padding:
    calc(var(--pad) + 28px + env(safe-area-inset-top, 0px))
    max(var(--pad), env(safe-area-inset-right, 0px))
    max(var(--pad), env(safe-area-inset-bottom, 0px))
    max(var(--pad), env(safe-area-inset-left, 0px));
  max-width: 1320px;
  margin: 0 auto;
  opacity: 0;
  transform: scale(1.02);
  filter: blur(12px);
  transition: opacity 1s var(--ease-out), transform 1.15s var(--ease-out), filter 1.15s var(--ease-out);
}

body.is-ready .stage {
  opacity: 1;
  transform: scale(1);
  filter: blur(0);
}

.identity {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 16px;
  min-height: 0;
  height: 100%;
}

.identity-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3rem, 8vw, 5.8rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
  text-transform: lowercase;
  background: linear-gradient(120deg, var(--ink) 30%, var(--accent) 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-role {
  margin-top: 12px;
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.hero-tagline {
  margin-top: 12px;
  max-width: 28ch;
  color: var(--ink-dim);
  font-family: var(--font-desc);
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  font-weight: 400;
  font-style: normal;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.project-tile-desc {
  margin-top: 0;
  color: var(--ink-dim);
  font-family: var(--font-desc);
  font-size: 0.86rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.45;
  letter-spacing: -0.01em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.identity-visual {
  width: min(42%, 180px);
  aspect-ratio: 1;
  position: relative;
  justify-self: start;
  will-change: transform;
  transition: transform 0.5s var(--ease-out);
}

.identity-visual::before {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 42% 58% 50% 50% / 48% 42% 58% 52%;
  background: radial-gradient(circle at 40% 35%, rgba(62, 207, 142, 0.5), transparent 62%);
  filter: blur(10px);
  animation: morph 9s ease-in-out infinite;
}

.identity-visual img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.5));
  animation: float-soft 5.5s ease-in-out infinite;
}

.stage-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-faint);
  font-size: 0.8rem;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.footer-links {
  display: flex;
  gap: 14px;
}

.footer-links a {
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 0.25s;
}

.footer-links a:hover {
  color: var(--accent);
}

/* ===== Works / projects ===== */
.works {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-height: 0;
  height: 100%;
}

.label {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 600;
}

.project-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-content: start;
  min-height: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 6px 14px;
  margin: -8px -6px -8px 0;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 35%, transparent) transparent;
}

@media (min-width: 1180px) {
  .project-tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.project-tile {
  position: relative;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--bg-elev) 75%, transparent);
  backdrop-filter: blur(10px);
  text-align: left;
  padding: 20px 18px 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  width: 100%;
  min-height: 0;
  cursor: pointer;
  opacity: 0;
  transform: translateY(28px) scale(0.96);
  transition: border-color 0.35s, box-shadow 0.45s, background 0.35s;
  isolation: isolate;
}

body.is-ready .project-tile:not(.is-settled) {
  animation: tile-in 0.65s var(--ease-out) both;
  animation-delay: calc(0.26s + var(--i, 0) * 0.08s);
}

.project-tile.is-settled {
  opacity: 1;
  transform: none;
  animation: none !important;
  transition: border-color 0.35s, box-shadow 0.45s, background 0.35s, transform 0.35s var(--ease-out);
}

a.project-tile {
  text-decoration: none;
  color: inherit;
}

.project-tile-top {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
}

.project-tile-heading {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.project-tile-year {
  color: var(--ink-faint);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.project-tile-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.project-tile-link {
  display: inline-block;
  margin-top: 0;
  font-family: var(--font-body);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.project-tile.is-settled:hover,
.project-tile.is-settled:focus-visible {
  outline: none;
  z-index: 2;
  border-color: rgba(62, 207, 142, 0.55);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(62, 207, 142, 0.15);
  transform: translateY(-4px);
  background: color-mix(in srgb, var(--bg-elev) 92%, #1a2a22);
}

.project-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(62, 207, 142, 0.22), transparent 45%);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  z-index: 0;
}

.project-tile:hover::before,
.project-tile:focus-visible::before {
  opacity: 1;
}

.project-tile > * {
  position: relative;
  z-index: 1;
}

.project-tile .project-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
  transition: transform 0.5s var(--ease-out);
}

.project-tile:hover .project-icon {
  transform: scale(1.1) rotate(-4deg);
}

.project-tile-name {
  font-family: var(--font-display);
  font-size: clamp(1.08rem, 1.5vw, 1.32rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.project-tile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 0;
  min-width: 0;
}

.project-tile-tags span {
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

body.is-ready [data-reveal] {
  opacity: 1;
  transform: none;
}

body.is-ready .identity-copy [data-reveal]:nth-child(1) { transition-delay: 0.2s; }
body.is-ready .identity-copy [data-reveal]:nth-child(2) { transition-delay: 0.3s; }
body.is-ready .identity-copy [data-reveal]:nth-child(3) { transition-delay: 0.38s; }
body.is-ready .stage-foot[data-reveal] { transition-delay: 0.46s; }
body.is-ready .works .label[data-reveal] { transition-delay: 0.28s; }

.projects-empty {
  color: var(--ink-faint);
  border: 1px dashed var(--line);
  padding: 12px;
  border-radius: 12px;
}

@keyframes pulse-orb {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.12); opacity: 1; }
}

@keyframes morph {
  0%, 100% { border-radius: 42% 58% 50% 50% / 48% 42% 58% 52%; }
  50% { border-radius: 55% 45% 42% 58% / 52% 58% 42% 48%; }
}

@keyframes float-soft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes boot-pulse {
  from { opacity: 0; letter-spacing: 0.2em; filter: blur(8px); }
  to { opacity: 1; letter-spacing: -0.04em; filter: blur(0); }
}

@keyframes tile-in {
  from { opacity: 0; transform: translateY(28px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mobile: page scroll on html (keeps pull-to-refresh in Chrome/Safari) */
@media (max-width: 860px) {
  html {
    height: 100%;
    overflow-x: hidden;
    overflow-y: scroll;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body {
    height: auto;
    min-height: 100%;
    overflow: visible;
    overscroll-behavior-y: auto;
  }

  .stage {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    padding-top: calc(52px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    gap: 20px;
    filter: none;
    transform: none;
  }

  body.is-ready .stage {
    filter: none;
    transform: none;
  }

  .identity {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 10px 16px;
    height: auto;
  }

  .identity-copy {
    justify-content: flex-start;
    grid-column: 1;
    grid-row: 1;
  }

  .identity-visual {
    width: clamp(104px, 28vw, 136px);
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    will-change: auto;
  }

  .identity-visual img {
    animation: none;
  }

  .brand {
    font-size: clamp(2.2rem, 11vw, 3rem);
  }

  .hero-role {
    margin-top: 8px;
  }

  .hero-tagline {
    display: none;
  }

  .stage-foot {
    grid-column: 1 / -1;
    grid-row: 2;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding-top: 10px;
  }

  .footer-links {
    flex-wrap: wrap;
    gap: 10px 14px;
    row-gap: 6px;
  }

  .works {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .project-tiles {
    grid-template-columns: 1fr;
    gap: 12px;
    height: auto;
    overflow: visible;
    overscroll-behavior: auto;
    margin: 0;
    padding: 0;
    touch-action: auto;
  }

  .project-tile {
    padding: 18px 18px 16px;
    border-radius: 16px;
    gap: 12px;
    backdrop-filter: none;
    background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  }

  .project-tile-foot {
    padding-top: 2px;
    gap: 10px;
  }

  .project-tile-tags {
    gap: 6px;
    padding-right: 4px;
  }

  .project-tile-tags span {
    padding: 5px 9px;
  }

  .project-tile .project-icon {
    width: 32px;
    height: 32px;
  }

  .project-tile-name {
    font-size: 1.05rem;
  }

  .project-tile-desc {
    -webkit-line-clamp: 2;
    font-size: 0.8rem;
  }
}

@media (max-width: 520px) {
  .project-tiles {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 700px) and (min-width: 861px) {
  .brand {
    font-size: clamp(2.2rem, 7vh, 3.6rem);
  }

  .identity-visual {
    width: min(28%, 120px);
  }

  .hero-tagline {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .boot {
    display: none;
  }

  .stage,
  [data-reveal],
  .project-tile {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
}
