/* ==========================================================================
   kurosubo.dev — On Track
   Tokens, base layout, and section styles. One signature scroll reveal
   (see .reveal), restrained everywhere else. Accent used sparingly.
   ========================================================================== */

/* ---- Tokens ------------------------------------------------------------ */
:root {
  --bg: #0a0a0b;
  --surface: #141417;
  --surface-2: #1c1c20;
  --text: #ececee;
  --muted: #8a8a90;
  --accent: #b18cff;
  --accent-rgb: 177, 140, 255;
  /* --accent-alt: #ff6a3d;  optional warmer swap — use one accent only */

  --font-display: "Clash Display", "Space Grotesk", sans-serif;
  --font-body: "Geist Sans", "Space Grotesk", sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", monospace;

  --container: min(1200px, 92vw);
  --gap: clamp(1rem, 2vw, 2rem);
  --section-pad: clamp(4rem, 10vw, 8rem);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Page transitions ---------------------------------------------------
   One fast, consistent transition for every page, so every nav destination
   feels the same: Cross-document View Transitions (Chromium) keep the
   outgoing page visible underneath while the incoming one slides over it;
   see .page-enter below for the (faster-still) local entrance every page
   also runs, timed to match so the handoff is seamless where both apply. */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: none;
}

::view-transition-new(root) {
  animation: page-slide-in 0.45s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes page-slide-in {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

/* Local entrance every page runs on load (nav, content and footer move as
   one, each animating its own transform so the nav's position:fixed
   containing block is never disturbed). Same duration/easing as the native
   transition above, small distance — this is the "every destination feels
   the same" baseline; nothing gets its own special-case animation. */
.nav,
#main,
.footer {
  animation: page-enter 0.45s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes page-enter {
  from {
    transform: translateX(16px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(root),
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
}

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

html {
  background: var(--bg);
  color-scheme: dark;
  scroll-behavior: auto; /* Lenis drives smooth scroll when active */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

a {
  color: inherit;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.02em;
}

p {
  max-width: 65ch;
}

/* ---- Focus states --------------------------------------------------------- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ---- Skip link ------------------------------------------------------------ */
.skip-link {
  position: fixed;
  top: -100%;
  left: 1rem;
  z-index: 1000;
  background: var(--accent);
  color: var(--bg);
  padding: 0.75rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
  border-radius: 4px;
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: 1rem;
}

/* ---- Preloader ------------------------------------------------------------ */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  cursor: pointer;
}

#preloader .preloader__mark {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

#preloader .preloader__count {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 5rem);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

#preloader .preloader__bar {
  width: min(240px, 60vw);
  height: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

#preloader .preloader__bar-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
}

body.is-loading {
  overflow: hidden;
}

/* ---- Nav ------------------------------------------------------------------ */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 1.25rem clamp(1.25rem, 4vw, 3rem);
  mix-blend-mode: difference;
}

.nav__brand {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1rem;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.nav__links {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.5vw, 2rem);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.nav__links a {
  position: relative;
  display: inline-block;
  padding-bottom: 0.3rem;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.2s var(--ease);
}

.nav__links a:hover,
.nav__links a:focus-visible {
  opacity: 1;
}

/* Single shared indicator that glides between links on hover/focus,
   instead of each link animating its own underline independently. */
.nav__indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 1px;
  width: 0;
  background: var(--accent);
  opacity: 0;
  transform: translateX(0);
  transition: transform 0.45s cubic-bezier(0.65, 0, 0.35, 1), width 0.45s cubic-bezier(0.65, 0, 0.35, 1),
    opacity 0.2s var(--ease);
  pointer-events: none;
}

.nav__offtrack {
  color: var(--accent);
}

.lang-switch {
  display: flex;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.lang-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  border-radius: 3px;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.is-active {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- Hero ------------------------------------------------------------------ */
.hero {
  position: relative;
  height: 100svh;
  min-height: 560px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  max-width: none;
  margin: 0;
  padding: 0;
}

.hero__content {
  position: relative;
  z-index: 2;
  padding: 0 clamp(1.25rem, 4vw, 3rem) clamp(9rem, 20vw, 15rem);
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(1rem, 3vw, 2rem);
}

.hero__text {
  min-width: 0;
  flex: 0 1 auto;
}

.hero__portrait {
  flex-shrink: 0;
  height: clamp(220px, 34vw, 480px);
  width: auto;
  object-fit: contain;
  -webkit-mask-image: linear-gradient(to bottom, black 78%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 78%, transparent 100%);
}

.hero__mark {
  font-family: var(--font-mono);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

.hero__name {
  font-size: clamp(3.5rem, 15vw, 12rem);
  line-height: 0.9;
  text-transform: uppercase;
  color: var(--text);
}

.hero__name span {
  display: block;
}

.hero__tagline {
  margin: 1.25rem 0 0;
  max-width: 42ch;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.25rem);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding: 0.4rem 0.9rem;
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.badge__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.6);
  animation: badge-pulse 2s ease-out infinite;
}

@keyframes badge-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.5);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(var(--accent-rgb), 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0);
  }
}

/* ---- Sections generic -------------------------------------------------- */
section {
  padding: var(--section-pad) clamp(1.25rem, 4vw, 3rem);
  max-width: var(--container);
  margin: 0 auto;
}

.section-heading {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

/* Signature scroll reveal — clip/mask on section headers, used consistently */
.reveal {
  overflow: hidden;
}

.reveal__inner {
  display: block;
  will-change: transform;
}

/* ---- About ------------------------------------------------------------- */
.about__body {
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.15rem);
}

.about__toggle {
  margin-top: 1.5rem;
}

.about__personal-life {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows 0.4s var(--ease);
}

.about__personal-life > * {
  min-height: 0;
  margin: 0;
  padding-top: 1.25rem;
}

.about__personal-life.is-open {
  grid-template-rows: 1fr;
}

#about {
  padding-bottom: clamp(1.5rem, 4vw, 3rem);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.25rem 0;
}

.tag-row li {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  border: 1px solid var(--surface-2);
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
}

/* ---- Work ---------------------------------------------------------------- */
#work {
  padding-top: clamp(1.5rem, 4vw, 3rem);
}

.work__project {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #12141f 0%, var(--surface) 55%);
  border-radius: 6px;
  border-top: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--accent), transparent 70%) 1;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.work__project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
}

.work__project-title {
  font-size: clamp(1.5rem, 3.2vw, 2.25rem);
}

.work__project-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.tag-row--work li {
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
}

.work__project-desc {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.15rem);
}

.work__project-bullets {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.work__project-bullets li {
  position: relative;
  padding-left: 1.25rem;
  max-width: 65ch;
}

.work__project-bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.work__project-note {
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
  border-radius: 4px;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease);
}

.btn--primary {
  background: var(--accent);
  color: var(--bg);
}

.btn--primary:hover {
  transform: translateY(-2px);
}

.btn--ghost {
  border: 1px solid var(--surface-2);
  color: var(--text);
}

.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Skills -------------------------------------------------------------- */
.tag-row--skills li {
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
}

.skills__intro {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1.5rem;
}

.skills__outro {
  margin: 2.5rem 0 0;
  max-width: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 4.5vw, 2.75rem);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.15;
  background: linear-gradient(90deg, var(--accent), #fff 45%, var(--accent) 90%);
  background-size: 220% auto;
  background-position: 0% center;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(177, 140, 255, 0.4);
  animation: skills-outro-shimmer 4s linear infinite;
}

@keyframes skills-outro-shimmer {
  to {
    background-position: 220% center;
  }
}

/* ---- Contact --------------------------------------------------------------- */
.contact__intro {
  color: var(--muted);
  margin-bottom: 2rem;
}

.contact__links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
}

.contact__links a {
  width: fit-content;
  text-decoration: none;
  border-bottom: 1px solid var(--surface-2);
  padding-bottom: 0.15rem;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.contact__links a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- Footer --------------------------------------------------------------- */
.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 2rem clamp(1.25rem, 4vw, 3rem) 3rem;
  max-width: var(--container);
  margin: 0 auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}

.footer a {
  color: var(--muted);
  text-decoration: none;
}

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

/* ---- Image placeholders ---------------------------------------------------- */
.img-placeholder {
  background: var(--surface);
  border: 1px dashed var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-align: center;
  padding: 1rem;
  aspect-ratio: 16 / 10;
  border-radius: 4px;
}

/* ---- Off Track stub -------------------------------------------------------- */
.off-track-main {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
  padding: 2rem;
}

.off-track-main h1 {
  font-size: clamp(2.5rem, 8vw, 5rem);
  text-transform: uppercase;
}

.off-track-main p {
  color: var(--muted);
  max-width: 42ch;
}

/* ---- Qualifications page --------------------------------------------------- */
.quals-page {
  background: radial-gradient(120% 55% at 50% 0%, #1c1e28 0%, var(--bg) 65%);
}

.quals-intro {
  padding-top: clamp(2rem, 6vw, 4rem);
  padding-bottom: 0;
}

.quals-intro__text {
  color: var(--muted);
}

.quals-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  padding-top: clamp(1.5rem, 4vw, 2.5rem);
}

.quals-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #12141f 0%, var(--surface) 55%);
  border-radius: 6px;
  border-top: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--accent), transparent 70%) 1;
  padding: clamp(1.5rem, 3vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Faint diagonal-line motif, a quiet nod to the certificate's own margin pattern */
.quals-card::before {
  content: "";
  position: absolute;
  inset: 0 0 0 55%;
  background: repeating-linear-gradient(
    115deg,
    rgba(var(--accent-rgb), 0.16) 0,
    rgba(var(--accent-rgb), 0.16) 1px,
    transparent 1px,
    transparent 7px
  );
  -webkit-mask-image: linear-gradient(to left, black, transparent);
  mask-image: linear-gradient(to left, black, transparent);
  pointer-events: none;
}

.quals-card > * {
  position: relative;
}

.quals-card__label {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.4);
  border-radius: 3px;
  padding: 0.25rem 0.6rem;
}

.quals-card--secondary .quals-card__label {
  color: var(--muted);
  border-color: var(--surface-2);
}

.quals-card__title {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
}

.quals-card--primary .quals-card__title {
  font-size: clamp(1.5rem, 3.2vw, 2.25rem);
}

.quals-card--secondary .quals-card__title {
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  color: var(--muted);
}

.quals-card__desc {
  color: var(--muted);
  margin: 0;
}

/* ---- Easter egg: jumpscare overlay (Off Track secret) --------------------- */
.jumpscare-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
}

.jumpscare-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
  animation: jumpscare-shake 0.4s ease-in-out 2;
}

.jumpscare-overlay img {
  max-width: 90vw;
  max-height: 90vh;
}

.jumpscare-overlay.is-active img {
  animation: jumpscare-pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes jumpscare-pop {
  0% {
    transform: scale(0.15) rotate(-6deg);
  }
  60% {
    transform: scale(1.25) rotate(3deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

@keyframes jumpscare-shake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-12px, 6px);
  }
  40% {
    transform: translate(10px, -8px);
  }
  60% {
    transform: translate(-8px, -4px);
  }
  80% {
    transform: translate(12px, 4px);
  }
}

/* ---- Responsive ------------------------------------------------------------ */
@media (max-width: 860px) {
  .nav__links {
    gap: 1rem;
  }

  .nav__links span,
  .nav__links a[href$="#about"],
  .nav__links a[href$="#contact"] {
    display: none;
  }

  .quals-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .nav__links {
    display: none;
  }
}

/* ---- Reduced motion --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .reveal__inner {
    transform: none !important;
  }

  #preloader {
    display: none !important;
  }
}
