:root {
  color-scheme: dark;
  --ink: #071216;
  --ink-soft: #0b1d22;
  --paper: #edf8f6;
  --muted: #a6bbb8;
  --line: rgba(166, 208, 201, 0.22);
  --accent: #8cbe3f;
  --accent-strong: #a8d85e;
  --panel-radius: 16px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  min-width: 320px;
  background: var(--ink);
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: Aptos, "Segoe UI Variable", "Noto Sans Sinhala", "Noto Sans Tamil", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: var(--panel-radius);
  background: var(--accent);
  color: #102009;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform 180ms var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wordmark {
  color: var(--paper);
  font-size: clamp(0.9rem, 1.3vw, 1.08rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  text-decoration: none;
  white-space: nowrap;
}

.wordmark strong {
  color: var(--accent-strong);
  font-weight: 750;
}

.brand-lockup {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  min-width: 0;
  justify-items: start;
  align-items: center;
}

.header-crest {
  grid-row: 1 / span 2;
  width: clamp(42px, 4.3vw, 54px);
  height: auto;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.28));
}

.brand-lockup .wordmark {
  align-self: end;
}

.department-cycle {
  align-self: start;
  max-width: min(42vw, 480px);
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.58rem, 0.72vw, 0.68rem);
  font-weight: 560;
  letter-spacing: 0.01em;
  line-height: 1.2;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 280ms ease, transform 280ms var(--ease-out);
}

.department-cycle.is-changing {
  opacity: 0;
  transform: translateY(-5px);
}

.text-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  background: rgba(7, 18, 22, 0.72);
  color: var(--paper);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: border-color 220ms ease, background-color 220ms ease, color 220ms ease, transform 220ms var(--ease-out);
}

.text-button:hover {
  border-color: rgba(168, 216, 94, 0.62);
  background: rgba(20, 43, 45, 0.9);
}

.text-button:active {
  transform: translateY(1px) scale(0.98);
}

.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  background: var(--ink);
  transition: transform 1.05s var(--ease-out), opacity 700ms ease;
}

.intro.is-exiting {
  pointer-events: none;
  transform: translateY(-104%);
  opacity: 0.82;
}

.intro.is-hidden {
  display: none;
}

.intro-backdrop {
  position: absolute;
  inset: -6%;
  background:
    linear-gradient(180deg, rgba(7, 18, 22, 0.18), rgba(7, 18, 22, 0.72)),
    image-set(
      url("assets/sinhala-720.webp") 1x,
      url("assets/sinhala-1200.webp") 2x
    ) center / cover no-repeat;
  filter: blur(30px) saturate(0.65);
  opacity: 0.34;
  transform: scale(1.08);
}

.intro-video {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 500ms ease, transform 900ms var(--ease-out);
}

.intro-video.is-ready {
  opacity: 1;
  transform: scale(1);
}

.intro-header,
.gallery-header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 72px;
  padding: max(14px, env(safe-area-inset-top)) clamp(18px, 3vw, 48px) 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(7, 18, 22, 0.78), rgba(7, 18, 22, 0));
}

.intro-header {
  grid-template-columns: 1fr;
}

.journey-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}

.intro-controls,
.gallery-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.intro-controls {
  position: absolute;
  right: clamp(18px, 3vw, 48px);
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 4;
}

.gallery-shell {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--ink);
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition: transform 1.2s var(--ease-out), opacity 600ms ease;
}

.intro-active .gallery-shell {
  opacity: 0.45;
  transform: scale(0.97);
}

.tunnel {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  overflow: hidden;
  perspective: 920px;
  perspective-origin: 50% 48%;
  background: var(--ink);
}

.portal-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7, 18, 22, 0.42), transparent 30%, rgba(7, 18, 22, 0.34)),
    url("assets/portal-background.webp") center / cover no-repeat;
  transform: scale(1.015);
}

.portal-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(7, 18, 22, 0.35), transparent 24%, transparent 72%, rgba(7, 18, 22, 0.58)),
    linear-gradient(180deg, rgba(7, 18, 22, 0.42), transparent 24%, transparent 72%, rgba(7, 18, 22, 0.72));
}

.tunnel-world {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.tunnel-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-style: preserve-3d;
  will-change: transform, opacity;
}

.tunnel-frame {
  width: clamp(250px, 29vw, 450px);
  aspect-ratio: 1;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(197, 232, 226, 0.42);
  border-radius: var(--panel-radius);
  background: #dceeed;
  box-shadow:
    0 20px 70px rgba(2, 10, 12, 0.52),
    inset 0 1px 0 rgba(255, 255, 255, 0.58),
    inset 0 0 26px rgba(168, 216, 94, 0.08);
}

.tunnel-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-brand {
  position: absolute;
  right: clamp(18px, 3vw, 48px);
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 5;
  width: clamp(148px, 15vw, 202px);
  overflow: hidden;
  border: 1px solid rgba(237, 248, 246, 0.36);
  border-radius: var(--panel-radius);
  background: #f7fbfa;
  box-shadow:
    0 18px 45px rgba(2, 10, 12, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.gallery-brand img {
  display: block;
  width: 100%;
  height: auto;
}

.typewriter-panel {
  position: absolute;
  top: 50%;
  right: clamp(18px, 3vw, 48px);
  z-index: 5;
  width: min(31vw, 390px);
  display: flex;
  align-items: center;
  min-height: 108px;
  padding: 18px 20px;
  border: 1px solid rgba(97, 186, 201, 0.36);
  border-radius: var(--panel-radius);
  background: rgba(7, 18, 22, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 24px 64px rgba(2, 10, 12, 0.38);
  transform: translateY(-50%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.typewriter-line {
  min-height: 2.8rem;
  margin: 0;
  color: var(--paper);
  font-size: clamp(1.5rem, 2.9vw, 2.65rem);
  font-weight: 720;
  letter-spacing: -0.045em;
  line-height: 1.12;
}

.typewriter-caret {
  display: inline-block;
  width: 2px;
  height: 0.9em;
  margin-left: 5px;
  background: var(--accent-strong);
  vertical-align: -0.05em;
  animation: caret-blink 720ms steps(1, end) infinite;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

.noscript-gallery {
  position: fixed;
  inset: 80px 0 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 16px;
  overflow: auto;
  background: var(--ink);
}

.noscript-gallery img {
  width: 100%;
  border-radius: var(--panel-radius);
}

@media (max-width: 767px) {
  .intro-header,
  .gallery-header {
    grid-template-columns: 1fr auto;
    min-height: 64px;
    padding-inline: 16px;
  }

  .journey-title {
    display: none;
  }

  .gallery-actions .text-button:last-child {
    display: none;
  }

  .intro-controls {
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: 16px;
  }

  .intro-controls .text-button {
    flex: 1;
  }

  .department-cycle {
    max-width: min(58vw, 250px);
    font-size: 0.56rem;
    line-height: 1.15;
  }

  .brand-lockup {
    column-gap: 8px;
  }

  .header-crest {
    width: 38px;
  }

  .tunnel {
    perspective: 760px;
  }

  .tunnel-frame {
    width: min(50vw, 280px);
  }

  .portal-backdrop {
    background-position: 42% center;
  }

  .typewriter-panel {
    top: 86px;
    right: 16px;
    left: 16px;
    width: auto;
    min-height: 74px;
    padding: 12px 14px;
    transform: none;
  }

  .typewriter-line {
    min-height: 1.9rem;
    font-size: 1.42rem;
  }

  .gallery-brand {
    right: 16px;
    bottom: max(18px, env(safe-area-inset-bottom));
    width: 112px;
  }

  .noscript-gallery {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .text-button,
  .typewriter-panel {
    background: var(--ink-soft);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .intro-active .gallery-shell,
  .gallery-shell,
  .intro-video {
    transform: none;
  }

  .typewriter-caret {
    animation: none;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  .intro-header,
  .gallery-header {
    min-height: 58px;
  }

  .typewriter-panel {
    top: 64px;
    right: 12px;
    left: auto;
    width: min(42vw, 300px);
    min-height: 74px;
  }
}
