/* Hide swipe arrow utility class */
.hide-arrow {
  display: none !important;
}

@keyframes swipeArrowLoop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(0);
  }
  10% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(32px);
  }
}

.swipe-arrow {
  position: fixed;
  left: 50%;
  bottom: 2.5vh;
  transform: translateX(-50%) translateY(0);
  width: 48px;
  height: auto;
  z-index: 100;
  pointer-events: none;
  animation: swipeArrowLoop 1.8s cubic-bezier(0.4,0,0.2,1) infinite;
}

@media (max-width: 600px) {
  .swipe-arrow {
    width: 36px;
    bottom: 2vh;
  }
}

body, html {
  margin: 0;
  padding: 0;
  /* Prevent native scrolling */
  overflow: hidden;
  /* disable browser touch panning so touch handlers control navigation */
  touch-action: none;
  height: 100svh;
  width: 100svw;
  font-family: 'Monaspace Krypton', monospace;
  scroll-behavior: smooth;
}

#spa-content {
  position: relative;
  height: 100svh;
  width: 100svw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  box-sizing: border-box;
  overflow: hidden;
}

#spa-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000;
  z-index: 3000;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  transition: opacity 0.35s cubic-bezier(0.4,0,0.2,1), visibility 0.35s cubic-bezier(0.4,0,0.2,1);
  pointer-events: all;
  opacity: 1;
  visibility: visible;
}
#spa-loading-overlay.hidden {
  display: none;
}

.spa-loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 2.5vw 2.5vh 0;
  z-index: 1001;
}

.loader {
  position: relative;
  border-top: 8px solid #fff;
  border-radius: 50%;
  width: 64px;
  height: 64px;
  animation: spin 1s linear infinite;
  margin-bottom: 0.7rem;
}

.loader-percent {
  color: var(--main-accent);
  font-size: 1.2rem;
  font-family: monospace;
  text-shadow: 0 2px 8px #222;
  letter-spacing: 0.05em;
}

/* Blurred background video */
.bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: -2;
  filter: blur(6px) brightness(0.85);
  pointer-events: none;
}

/* Profile image gradient background and positioning */
.profile-img-gradient {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.profile-img-gradient::before {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle at 70% 50%, #b2f7b8 0%, #eaffea 60%, rgba(178,247,184,0) 100%);
  z-index: 0;
  filter: blur(8px);
}

.profile-img {
  max-width: 220px;
  width: 60vw;
  border-radius: 1.2rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  position: relative;
  z-index: 1;
  margin-right: 2vw;
}

footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 3rem;
  gap: 1rem;
  padding-bottom: 2.5rem;
}

footer a {
  display: inline-block;
  padding: 0.75rem 2rem;
  margin: 0 0.5rem;
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: var(--main-accent);
  font-weight: 600;
  text-decoration: none;
  font-size: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: all 0.25s ease;
}
footer a:hover {
  background: var(--main-accent);
  color: var(--main-text);
  transform: translateY(-2px);
}

header, footer, section {
  padding: 20px;
  text-align: center;
}

h1, h2 {
  margin: 10px 0;
}

/* Center SPA headers */
#spa-content h1 {
  text-align: center;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Reserve space for sub-intro to prevent hero jitter during typing */
.sub-intro {
  display: block;
  min-height: 1.4em; /* keeps vertical space even when empty */
}
.sub-intro:empty::before {
  content: "\00A0"; /* non-breaking space to hold line-height */
}

.project-cards {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 2rem;
  margin: 2rem 0;
  flex-wrap: wrap;
}

.projectcard {
  background: rgba(128, 128, 128, 0.18);
  border-radius: 1rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 1.5px 4px rgba(0,0,0,0.06);
  padding: 2rem 1.5rem;
  min-width: 220px;
  max-width: 300px;
  flex: 1 1 220px;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  backdrop-filter: blur(1px);
  color: #222;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.projectcard:hover {
  transform: translateY(-8px) scale(1.03);
  /* fallback subtle shadow for older browsers */
  box-shadow: 0 8px 24px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.10);
  /* modern browsers: use a softened tint of the page background for the glow */
  box-shadow: 0 8px 24px color-mix(in srgb, var(--main-bg) 18%, black 82%), 0 2px 8px rgba(0,0,0,0.10);
  background: rgba(128, 128, 128, 0.28);
}

.projectcard h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
  font-size: 1.3rem;
  color: var(--main-accent);
}

.projectcard p {
  margin: 0;
  font-size: 1rem;
  color: #333;
}

.projectcard a {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-family: 'Monaspace Krypton', monospace;
  text-rendering: optimizeLegibility;
}

.wavy-text {
  font-size: clamp(1.3rem, 6vw, 2.5rem);
  flex-wrap: wrap;
  word-break: break-word;
  white-space: normal;
  padding: 0.5em 0.2em;
  line-height: 1.2;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* Time-based theme color classes */
.theme-morning {
  --main-bg: #ffeabf;
  --main-accent: #ffb347;
  --main-text: #3a2c0a;
  background-color: var(--main-bg);
  /* Menu palette for morning: overlay uses page text, pills use accent */
  --menu-bg: var(--main-text);
  --menu-text: var(--main-accent);
  --menu-pill: var(--main-accent);
}

body.theme-afternoon.bg-afternoon1 {
  --main-bg: #00B3C6;
  --main-accent: #F5F7FA;
  --main-text: #00B3C6;
  background-color: var(--main-bg);
  /* Menu defaults for afternoon */
  --menu-bg: rgba(34,34,34,0.97);
  --menu-text: var(--main-text);
  --menu-pill: var(--main-accent);
}

body.theme-afternoon.bg-afternoon2 {
  --main-bg: #E3E0DD;
  --main-accent: #E3E0DD;
  --main-text: #A9746E;
  background-color: var(--main-bg);
  --menu-bg: rgba(34,34,34,0.97);
  --menu-text: var(--main-text);
  --menu-pill: var(--main-accent);
}

.theme-evening {
  --main-bg: #BFB9B0;
  --main-accent: #BFB9B0;
  --main-text: #475C6E;
  background-color: var(--main-bg);
  --menu-bg: rgba(34,34,34,0.97);
  --menu-text: var(--main-text);
  --menu-pill: var(--main-accent);
}
.theme-night {
  --main-bg: #232946;
  --main-accent: #A6A6A6;
  --main-text: #2E2E2E;
  background-color: var(--main-bg);
  /* Night menu: overlay uses accent, pills/text swap */
  --menu-bg: var(--main-accent);
  --menu-text: var(--main-text);
  --menu-pill: var(--main-text);
}

/* Example usage for accent: */
.button, .pill {
  background: var(--main-accent);
  color: var(--main-text);
}

/* Headers use the main text color for prominence */
body.theme-morning h1, body.theme-morning h2, body.theme-morning h3,
body.theme-afternoon h1, body.theme-afternoon h2, body.theme-afternoon h3,
body.theme-evening h1, body.theme-evening h2, body.theme-evening h3,
body.theme-night h1, body.theme-night h2, body.theme-night h3 {
  color: var(--main-text) !important;
}

/* Small/secondary text (paragraphs, smalls, project descriptions) use the accent */
body.theme-morning p, body.theme-morning small, body.theme-morning .projectcard p,
body.theme-afternoon p, body.theme-afternoon small, body.theme-afternoon .projectcard p,
body.theme-evening p, body.theme-evening small, body.theme-evening .projectcard p,
body.theme-night p, body.theme-night small, body.theme-night .projectcard p,
body.theme-afternoon.bg-afternoon2 p, body.theme-afternoon.bg-afternoon2 small {
  color: var(--main-accent) !important;
}

/* Keep interactive accents readable: ensure buttons/pills and nav use the accent and text vars */
.button, .pill, .menu-nav a, .menu-nav a.active {
  color: var(--main-text);
}
/* Buttons and pills use the accent by default (no !important so hover rules can override) */
.button, .pill {
  background: var(--main-accent);
}
/* Active nav link uses the menu pill variable (per-theme) */
.menu-nav a.active {
  background: var(--menu-pill);
}

/* Button/pill hover: invert to main-text background with accent text */
.button:hover, .pill:hover {
  /* On hover, ensure the button text becomes the page's main text color (theme-driven) */
  background: var(--main-accent);
  color: var(--main-text);
  border: 2px solid var(--main-accent);
}

/* Make interactive buttons consistent size and center their text
   Applies to footer buttons, generic .button/.pill and menu nav links. */
.button, .pill, footer a, .menu-nav a, .menu-nav a.active {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  /* Keep padding consistent while allowing wrapping on very small screens */
  padding: 0.75rem 1.5rem;
  min-width: 160px;
  box-sizing: border-box;
  line-height: 1;
  white-space: nowrap;
}

/* Allow menu links to shrink on very narrow screens while still centering text */
@media (max-width: 420px) {
  .button, .pill, footer a, .menu-nav a, .menu-nav a.active {
    min-width: 120px;
    padding: 0.6rem 1rem;
    white-space: normal;
  }
}

/* Staggered fade / lift entrance for page fragments */
.fade-scale.in h2,
.fade-scale.in p,
.fade-scale.in a {
  opacity: 1;
  transform: translateY(0);
  animation: fadeUp 0.6s cubic-bezier(0.4,0,0.2,1) forwards;
  animation-fill-mode: forwards;
}

@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Inside #spa-content, stack pages for smooth crossfades */
#spa-content {
  position: relative;
  overflow: hidden;
}

#spa-content > .fade-scale {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  /* Re-enable flex centering for each page */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Direction-aware fade-slide animations */
.fade-scale {
  opacity: 0;
  transform: translateY(0);
  transition:
    opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-scale.in {
  opacity: 1;
  transform: translateY(0);
}

/* Pre-entry offsets for directional motion */
.fade-scale.slide-up {
  transform: translateY(24px); /* entering from below */
}
.fade-scale.slide-down {
  transform: translateY(-24px); /* entering from above */
}
