/* =============================================================
   Kairos Shell — Embossed Liquid Text Design
   "Letters carved INTO the wall, filled with colored liquid"
   
   Technique:
   - Text is transparent with layered text-shadow = carved 3D depth
   - A colored liquid layer clips to text shape and animates fill level
   - Transitions: liquid drains → text morphs → new liquid fills
   ============================================================= */

/* === Animatable Custom Properties === */
@property --liquid-color {
  syntax: '<color>';
  inherits: true;
  initial-value: #4F46E5;
}
@property --liquid-color-light {
  syntax: '<color>';
  inherits: true;
  initial-value: #818CF8;
}
/* --fill-pos: 0% = empty (cavity shadow visible), 100% = full (liquid visible) */
/* Set by JS. No @property needed since we don't animate it via CSS transitions — JS handles the easing. */

/* === Root Variables === */
:root {
  /* Liquid state */
  --liquid-color: #4F46E5;
  --liquid-color-light: #818CF8;
  /* fill-pos: 0% = empty (cavity color shows), 100% = full (liquid color shows) */
  /* background-size is 100% 200%, so position 0% shows top half (cavity), 100% shows bottom half (liquid) */
  --fill-pos: 100%;  /* start full */

  /* Wave animation offsets */
  --wave1-x: 0px;
  --wave2-x: 80px;
  --wave-y: 0px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Wall / wall color */
  --wall: #F0EEEA;
  --wall-dark: #E8E5E0;
  --wall-shadow: rgba(0, 0, 0, 0.22);
  --wall-highlight: rgba(255, 255, 255, 0.95);

  /* Carved cavity:
     Light mode: the inside of the groove is a subtle warm shadow.
     Even when empty (no liquid), text is visible as medium gray engraving.
  */
  --cavity-color:      rgba(0, 0, 0, 0.22);    /* Visible medium gray — clearly readable as engraving */
  --cavity-color-mid:  rgba(0, 0, 0, 0.32);
  --cavity-rim-dark:   rgba(0, 0, 0, 0.45);    /* Sharp rim shadow */
  --cavity-rim-light:  rgba(255, 255, 255, 0.95); /* Bright lit rim */

  /* Card / UI surfaces */
  --surface: #F7F5F2;
  --border: #DDD9D3;
  --border-strong: #C8C3BB;
  --text-ui: #2D2B28;
  --text-muted: #7A7570;

  /* Liquid murk — makes the liquid look opaque/turbid */
  --liquid-murk: 0.82;  /* How solid the liquid looks (0=clear, 1=opaque) */

  /* Radii & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.10);
  --transition-fast: 200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Transition liquid props */
  transition:
    --liquid-color 600ms ease,
    --liquid-color-light 600ms ease;
}

/* === Dark Mode === */
:root.dark-mode {
  --wall: #1A1916;
  --wall-dark: #121210;
  --wall-shadow: rgba(0, 0, 0, 0.8);
  --wall-highlight: rgba(255, 255, 255, 0.12);
  /* Dark mode cavity:
     Wall is dark, groove interior appears lighter — like a light-catching groove.
     Empty text = clearly visible silver/gray hint against the dark wall.
  */
  --cavity-color:      rgba(255, 255, 255, 0.22);
  --cavity-color-mid:  rgba(255, 255, 255, 0.30);
  --cavity-rim-dark:   rgba(0, 0, 0, 0.80);    /* Deep outer shadow */
  --cavity-rim-light:  rgba(255, 255, 255, 0.25);
  --surface: #242220;
  --border: #333128;
  --border-strong: #48453D;
  --text-ui: #EDEAE4;
  --text-muted: #888279;
}


/* =============================================================
   RESET & BASE
   ============================================================= */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--wall);
  color: var(--text-ui);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background 400ms ease, color 400ms ease;
}


/* =============================================================
   WALL TEXTURE — Subtle grain + vignette from corners
   ============================================================= */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    /* Noise grain */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.028'/%3E%3C/svg%3E"),
    /* Corner vignettes — mimicking a room's ambient occlusion */
    radial-gradient(ellipse 80% 60% at 0% 0%, rgba(0,0,0,0.09), transparent),
    radial-gradient(ellipse 80% 60% at 100% 0%, rgba(0,0,0,0.06), transparent),
    radial-gradient(ellipse 60% 50% at 0% 100%, rgba(0,0,0,0.07), transparent),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(0,0,0,0.05), transparent),
    /* Center light — like a ceiling light */
    radial-gradient(ellipse 55% 40% at 50% 0%, rgba(255,255,255,0.25), transparent 60%);
}

body > * { position: relative; z-index: 1; }


/* =============================================================
   CONTAINER & LAYOUT
   ============================================================= */
.container { width: 90%; max-width: 1200px; margin: 0 auto; }
#content { flex: 1; }


/* =============================================================
   NAVIGATION — Frosted wall surface
   ============================================================= */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--wall) 85%, transparent);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border-bottom: 1px solid var(--border);
  transition: background 400ms ease, border-color 400ms ease;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 16px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text-ui);
  text-decoration: none;
  flex-shrink: 0;
}

.nav-logo-icon {
  width: 30px;
  height: 30px;
  background: var(--liquid-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 13px;
  transition: background 600ms ease;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: center;
}

.nav-link {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  white-space: nowrap;
}
.nav-link:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text-ui);
}
:root.dark-mode .nav-link:hover {
  background: rgba(255,255,255,0.07);
}
.nav-link.active {
  background: color-mix(in srgb, var(--liquid-color) 12%, transparent);
  color: var(--liquid-color);
  transition: background 600ms ease, color 600ms ease;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Dark mode toggle */
.dark-toggle {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}
.dark-toggle:hover {
  background: rgba(0,0,0,0.06);
  color: var(--text-ui);
}
:root.dark-mode .dark-toggle:hover {
  background: rgba(255,255,255,0.08);
}


/* =============================================================
   USER DROPDOWN
   ============================================================= */
#kn-user-dropdown { position: relative; }
.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--liquid-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition-fast), background 600ms ease;
}
.nav-avatar:hover { border-color: var(--border-strong); }

#kn-user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 175px;
  display: none;
  overflow: hidden;
  z-index: 200;
  transition: background 400ms ease;
}
#kn-user-menu.active { display: block; }

.menu-header {
  padding: 10px 15px;
  font-size: 0.72rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.menu-header strong { color: var(--text-ui); display: block; }
.menu-item {
  display: block;
  padding: 9px 15px;
  color: var(--text-ui);
  text-decoration: none;
  font-size: 0.82rem;
  transition: background var(--transition-fast);
  border-bottom: 1px solid rgba(0,0,0,0.03);
}
.menu-item i { margin-right: 6px; width: 14px; text-align: center; color: var(--text-muted); }
.menu-item:hover { background: rgba(0,0,0,0.04); }
:root.dark-mode .menu-item:hover { background: rgba(255,255,255,0.05); }
.menu-item.logout { color: #E53E3E; }
.menu-item.logout:hover { background: rgba(229, 62, 62, 0.07); }


/* =============================================================
   ✦ EMBOSSED TEXT EFFECT ✦
   
   Concept:
   - Text is rendered as a CARVING in the wall surface.
   - The carving (cavity) is always visible: dark interior + lit rims.
   - Liquid fills from the bottom: SOLID, OPAQUE color — not transparent.
   - A hard gradient stop separates liquid (bottom) from cavity shadow (top).
   - This means text is ALWAYS readable — filled = liquid color, empty = shadow.
   
   Gradient structure (background-clip: text):
   [0% → fill%]   = solid liquid color  (the murky liquid)  
   [fill% → fill%] = hard edge (liquid surface with glow)
   [fill% → 100%] = dark cavity shadow  (the empty engraving interior)
   ============================================================= */

/* Apply embossed effect to all page text elements */
.page h1,
.page h2,
.page h3,
.page p,
.page li,
.page .card-action {
  color: transparent;
  /* WebKit requires this to clip the background through the glyph shape */
  -webkit-text-fill-color: transparent;
}

/* ── HEADINGS (h1, h2) — Deeper carving, stronger shadows —─ */
.page h1, .page h2 {
  text-shadow:
    /* Cavity rim: sharp dark top-left shadow (light source from upper-right) */
    -1px -2px 0px var(--cavity-rim-dark),
    -2px -3px 4px color-mix(in srgb, var(--cavity-rim-dark) 55%, transparent),
    /* Lit rim: bright bottom-right highlight (opposite of shadow) */
    1px  2px 0px var(--cavity-rim-light),
    2px  3px 1px color-mix(in srgb, var(--cavity-rim-light) 70%, transparent),
    /* Soft outer glow below (adds depth/elevation feel) */
    0px  6px 16px color-mix(in srgb, var(--wall-shadow) 18%, transparent);

  /*
   * Gradient layout (background is 200% tall, bg-position animates 0→100%):
   *   0%   position = shows TOP half = cavity (very faint gray/white — readable)
   *   100% position = shows BOTTOM half = liquid (bright, pure module color)
   *
   * Stops in the 200% gradient:
   *   0–45%:   cavity interior (faint, NOT black)
   *   49–50%:  glow surface line
   *   52–100%: liquid (pure saturated color)
   */
  background: linear-gradient(
    to bottom,
    /* TOP — Cavity interior: faint shadow, always readable */
    var(--cavity-color) 0%,
    var(--cavity-color-mid) 45%,
    /* Liquid surface glow */
    color-mix(in srgb, white 45%, var(--liquid-color-light)) 49%,
    var(--liquid-color-light) 50%,
    /* BOTTOM — Liquid: pure, opaque, saturated — rich color! */
    var(--liquid-color-light) 52%,
    var(--liquid-color) 100%
  );
  background-size: 100% 200%;
  background-position: 0 var(--fill-pos);
  -webkit-background-clip: text;
  background-clip: text;
  transition:
    background 600ms ease,
    text-shadow 400ms ease;
}

/* ── BODY TEXT (h3, p, li, card-action) — Lighter carving ── */
.page h3,
.page p,
.page li,
.page .card-action {
  text-shadow:
    -1px -1px 0px var(--cavity-rim-dark),
    -1px -2px 2px color-mix(in srgb, var(--cavity-rim-dark) 50%, transparent),
    1px  1px 0px var(--cavity-rim-light),
    1px  2px 1px color-mix(in srgb, var(--cavity-rim-light) 55%, transparent);

  background: linear-gradient(
    to bottom,
    var(--cavity-color) 0%,
    var(--cavity-color-mid) 45%,
    color-mix(in srgb, white 45%, var(--liquid-color-light)) 49%,
    var(--liquid-color-light) 51%,
    var(--liquid-color) 100%
  );
  background-size: 100% 200%;
  background-position: 0 var(--fill-pos);
  -webkit-background-clip: text;
  background-clip: text;
  transition:
    background 600ms ease;
}

/* Footer text — subtle carved look but always readable */
footer p, footer a, footer li {
  color: var(--text-muted);
  text-shadow:
    1px 1px 0 var(--wall-highlight),
    -1px -1px 0 color-mix(in srgb, var(--wall-shadow) 30%, transparent);
  transition: color 400ms ease;
}
footer a { text-decoration: none; }
footer a:hover { color: var(--liquid-color); }


/* =============================================================
   EXCLUDE interactive elements from the carved effect
   Only resets elements that should NOT have the gradient text effect.
   IMPORTANT: Do NOT include .btn here — it would nuke button backgrounds!
   ============================================================= */
.nav-link,
.nav-logo,
.nav-logo *,
.nav-logo-icon,
.menu-item,
.menu-header,
.menu-header strong,
.dark-toggle,
.card-icon,
.card-icon i,
.card-icon .emoji,
.hamburger,
.nav-avatar {
  color: initial !important;
  background: initial !important;
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  text-shadow: none !important;
  filter: none !important;
  -webkit-text-fill-color: initial !important;
}

/* Buttons: explicit reset — always override any gradient bleed-through */
.btn {
  -webkit-background-clip: initial !important;
  background-clip: initial !important;
  text-shadow: none !important;
  -webkit-text-fill-color: initial !important;
}
.btn-accent {
  background: var(--liquid-color) !important;
  color: white !important;
  -webkit-text-fill-color: white !important;
  transition: background 600ms ease, transform var(--transition-fast), box-shadow var(--transition-fast) !important;
}
.btn-outline {
  background: transparent !important;
  color: var(--liquid-color) !important;
  -webkit-text-fill-color: var(--liquid-color) !important;
  border-color: var(--liquid-color) !important;
  transition: background 600ms ease, color 600ms ease, border-color 600ms ease, transform var(--transition-fast) !important;
}

/* Nav items */
.nav-link { color: var(--text-muted) !important; }
.nav-link.active { color: var(--liquid-color) !important; background: color-mix(in srgb, var(--liquid-color) 12%, transparent) !important; }
.nav-link:hover { background: rgba(0,0,0,0.05) !important; color: var(--text-ui) !important; }
:root.dark-mode .nav-link:hover { background: rgba(255,255,255,0.07) !important; }


/* =============================================================
   HERO SECTION
   ============================================================= */
.hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 130px 20px 90px;
  min-height: 500px;
}
.hero h1 {
  font-size: clamp(2.8rem, 6vw, 4.5rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 800;
  margin-bottom: 24px;
  max-width: 820px;
}
.hero-sub {
  font-size: 1.1rem;
  max-width: 580px;
  margin-bottom: 44px;
}
.hero-buttons {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}


/* =============================================================
   BUTTONS — Solid raised surface on the wall
   ============================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  font-family: var(--font);
  transition: all var(--transition-fast);
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn-accent {
  background: var(--liquid-color);
  color: white !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: all var(--transition-fast), background 600ms ease;
}
.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 18px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-outline {
  background: transparent;
  color: var(--liquid-color) !important;
  border: 2px solid var(--liquid-color);
  transition: all var(--transition-fast), color 600ms ease, border-color 600ms ease;
}
.btn-outline:hover {
  background: color-mix(in srgb, var(--liquid-color) 8%, transparent);
  transform: translateY(-1px);
}
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }


/* =============================================================
   FLOOR CARDS — Tiles on the wall surface
   ============================================================= */
.floor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow:
    var(--shadow-sm),
    inset 0 1px 0 rgba(255,255,255,0.7);
  transition: all 300ms ease, background 400ms ease, border-color 400ms ease;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
:root.dark-mode .floor-card {
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.04);
}
.floor-card:hover {
  transform: translateY(-3px);
  box-shadow:
    0 4px 16px rgba(0,0,0,0.09),
    0 12px 32px rgba(0,0,0,0.06),
    inset 0 1px 0 rgba(255,255,255,0.7);
  border-color: var(--border-strong);
}
:root.dark-mode .floor-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 12px 32px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.04);
}

.card-icon {
  font-size: 1.8rem;
  margin-bottom: 14px;
  line-height: 1;
}
.card-icon .emoji { font-size: 1.8rem; }
.card-icon i {
  color: var(--liquid-color) !important;
  transition: color 600ms ease;
}
.floor-card h3 { margin-bottom: 8px; }
.floor-card p { flex-grow: 1; font-size: 0.9rem; }

.card-action {
  display: inline-block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 16px;
}
a.floor-card:hover .card-action { text-decoration: underline; }


/* =============================================================
   CONTENT SECTIONS
   ============================================================= */
.content-section {
  padding: 90px 0;
  border-top: 1px solid var(--border);
  transition: border-color 400ms ease;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 22px;
}
.cta-section {
  padding: 110px 0;
  text-align: center;
}
.cta-section .hero-sub {
  margin: 20px auto 36px;
}
.section-title {
  text-align: center;
  margin-bottom: 56px;
  font-size: 2rem;
  letter-spacing: -0.02em;
}


/* =============================================================
   FOOTER
   ============================================================= */
footer {
  text-align: center;
  padding: 40px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  margin-top: auto;
  transition: border-color 400ms ease;
}
.footer-links {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}
.footer-links a { transition: color var(--transition-fast); }


/* =============================================================
   PAGE SYSTEM — SPA show/hide with fade
   ============================================================= */
.page {
  display: none;
  opacity: 0;
  transition: opacity 350ms ease;
}
.page.active {
  display: block;
  opacity: 1;
  animation: pageIn 450ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.page.fade-out {
  animation: pageFadeOut 300ms ease forwards;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pageFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}


/* =============================================================
   MOBILE HAMBURGER
   ============================================================= */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-ui) !important;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}


/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 900px) {
  .hero { padding: 90px 20px 70px; min-height: auto; }
  .hero h1 { font-size: clamp(2.2rem, 6vw, 3.5rem); }
  .section-title { font-size: 1.7rem; }
  .content-section { padding: 70px 0; }
}

@media (max-width: 768px) {
  .hamburger { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 61px;
    left: 0;
    right: 0;
    background: color-mix(in srgb, var(--wall) 95%, transparent);
    backdrop-filter: blur(20px);
    flex-direction: column;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    gap: 2px;
    z-index: 99;
    justify-content: flex-start;
  }
  .nav-links.open { display: flex; }
  .nav-link { width: 100%; padding: 10px 12px; }
  .hero-buttons { flex-direction: column; width: 100%; max-width: 280px; }
  .hero-buttons .btn { width: 100%; justify-content: center; }
  .card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 2rem; }
  .section-title { font-size: 1.45rem; margin-bottom: 36px; }
  .hero { padding: 70px 16px 50px; }
  .floor-card { padding: 20px; }
}
