/* Self-hosted font faces */
@font-face {
  font-family: 'VT323';
  src: url('../fonts/VT323-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../fonts/IBMPlexMono-Light.woff2') format('woff2');
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../fonts/IBMPlexMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

/* Catppuccin Mocha Color Palette */
:root {
  --ctp-base: #1e1e2e;
  --ctp-mantle: #181825;
  --ctp-crust: #11111b;
  --ctp-text: #cdd6f4;
  --ctp-blue: #89b4fa;
  --ctp-lavender: #b4befe;
  --ctp-sapphire: #74c7ec;
  --ctp-teal: #94e2d5;
  --ctp-green: #a6e3a1;
  --ctp-yellow: #f9e2af;
  --ctp-peach: #fab387;
  --ctp-mauve: #cba6f7;
  --ctp-pink: #f5c2e7;
  --ctp-red: #f38ba8;
  --ctp-surface0: #313244;
  --ctp-surface1: #45475a;
  --ctp-overlay0: #6c7086;
  --ctp-base-65: rgba(30, 30, 46, 0.65);
  --ctp-base-92: rgba(30, 30, 46, 0.92);
}

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

/* Full-screen layout with no overflow */
html {
  margin: 0;
  padding: 0;
  overflow: hidden;
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  width: 100%;
  height: 100%;
  background-color: var(--ctp-base);
}

/* Full-screen canvas as base layer */
#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1;
  border: none;
  outline: none;
  touch-action: none;
}

/* Entrance animations */
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUpSubtle {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 0.65; transform: translateY(0); }
}

@keyframes hintFadeInOut {
  0% { opacity: 0; transform: translateY(8px); }
  12% { opacity: 0.5; transform: translateY(0); }
  70% { opacity: 0.5; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(0); }
}

/* Content overlay container */
.content-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vmin, 32px);
  padding: clamp(16px, 4vmin, 48px);
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: none;
}

/* Re-enable pointer events on interactive elements */
.title-section,
.contact-tiles,
.tortoise-tile {
  pointer-events: auto;
}

/* Title section */
.title-section {
  background: var(--ctp-base-65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(205, 214, 244, 0.15);
  border-radius: 16px;
  padding: 24px 32px;
  text-align: center;
  max-width: 90vw;
  animation: fadeIn 0.3s ease-out both;
}

/* Name heading — terminal/pixel font */
.name {
  font-family: 'VT323', monospace;
  font-size: clamp(44px, 10vw, 80px);
  font-weight: 400;
  color: var(--ctp-text);
  margin: 0;
  letter-spacing: 0.05em;
}

/* Blinking cursor */
.cursor {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Tagline — uppercase, light, subtle */
.tagline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  font-weight: 300;
  color: var(--ctp-text);
  opacity: 0;
  height: 0;
  overflow: hidden;
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Contact tiles cluster */
.contact-tiles {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

/* Contact tile base */
.contact-tile {
  background: var(--ctp-base-65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  opacity: 0;
}

/* Contact tile SVG */
.contact-tile svg {
  width: 24px;
  height: 24px;
}

/* Email tile */
.contact-email {
  color: var(--ctp-blue);
  border: 1px solid rgba(137, 180, 250, 0.3);
}

.contact-email:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(137, 180, 250, 0.4);
}

.contact-email:focus-visible {
  outline: 2px solid var(--ctp-blue);
  outline-offset: 3px;
}

/* GitHub tile */
.contact-github {
  color: var(--ctp-lavender);
  border: 1px solid rgba(180, 190, 254, 0.3);
}

.contact-github:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(180, 190, 254, 0.4);
}

.contact-github:focus-visible {
  outline: 2px solid var(--ctp-lavender);
  outline-offset: 3px;
}

/* LinkedIn tile */
.contact-linkedin {
  color: var(--ctp-sapphire);
  border: 1px solid rgba(116, 199, 236, 0.3);
}

.contact-linkedin:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(116, 199, 236, 0.4);
}

.contact-linkedin:focus-visible {
  outline: 2px solid var(--ctp-sapphire);
  outline-offset: 3px;
}

/* Tortoise shelter tile overlay */
.tortoise-tile {
  position: relative;
  z-index: 10;
  background: var(--ctp-base-65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(166, 227, 161, 0.15);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  color: #a6e3a1;
  text-decoration: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  opacity: 0;
}

.tortoise-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3),
              0 0 12px rgba(166, 227, 161, 0.15);
}

.tortoise-tile:focus-visible {
  outline: 2px solid #a6e3a1;
  outline-offset: 3px;
}

.tortoise-icon {
  font-size: 20px;
  line-height: 1;
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Turtle waddle: gentle rock + grow on hover */
@keyframes turtleWaddle {
  0%, 100% { transform: scale(1.2) rotate(0deg); }
  25% { transform: scale(1.25) rotate(-10deg) translateX(-1px); }
  75% { transform: scale(1.25) rotate(10deg) translateX(1px); }
}

.tortoise-tile:hover .tortoise-icon {
  animation: turtleWaddle 1.2s ease-in-out infinite;
}

.tortoise-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tortoise-text strong {
  font-weight: 600;
  font-size: 12px;
}

.tortoise-label {
  font-size: 11px;
  opacity: 0.7;
}

/* Canvas interaction hint */
.canvas-hint {
  position: fixed;
  bottom: clamp(24px, 4vmin, 40px);
  left: 0;
  right: 0;
  text-align: center;
  font-family: 'VT323', monospace;
  font-size: 20px;
  color: var(--ctp-overlay0);
  pointer-events: none;
  opacity: 0;
  z-index: 10;
  margin: 0;
}

/* Post-typewriter reveal animations */
.content-overlay.revealed .tagline {
  height: auto;
  overflow: visible;
  margin-top: 8px;
  animation: fadeInUpSubtle 0.4s ease-out both;
}

.content-overlay.revealed .contact-tile {
  animation: slideInRight 0.4s ease-out both;
}

.content-overlay.revealed .contact-tile:nth-child(1) { animation-delay: 0.15s; }
.content-overlay.revealed .contact-tile:nth-child(2) { animation-delay: 0.25s; }
.content-overlay.revealed .contact-tile:nth-child(3) { animation-delay: 0.35s; }

.content-overlay.revealed .tortoise-tile {
  animation: fadeInUp 0.4s ease-out 0.5s both;
}

.content-overlay.revealed .canvas-hint {
  animation: hintFadeInOut 5s ease 0.8s both;
}

/* Noscript fallback */
.noscript-fallback {
  background: var(--ctp-base);
  color: var(--ctp-text);
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  text-align: center;
}

.noscript-fallback h1 {
  font-size: 24px;
  margin: 0 0 8px;
}

.noscript-fallback p {
  font-size: 14px;
  margin: 0;
}

.noscript-fallback .noscript-tagline {
  opacity: 0.7;
  margin-bottom: 16px;
}

.noscript-fallback a {
  color: var(--ctp-blue);
}

/* Backdrop-filter fallback */
@supports not (backdrop-filter: blur(1px)) {
  .title-section,
  .contact-tile,
  .tortoise-tile {
    background: var(--ctp-base-92);
  }
}

/* Desktop media query */
@media (min-width: 768px) {
  .content-overlay {
    justify-content: space-between;
    align-items: stretch;
    padding: clamp(32px, 5vmin, 64px);
  }

  .title-section {
    align-self: flex-start;
    text-align: left;
  }

  .contact-tile {
    width: 56px;
    height: 56px;
  }

  .bottom-group {
    align-self: flex-end;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: clamp(16px, 3vmin, 32px);
    margin-top: auto;
  }

  body {
    overflow: hidden;
  }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  .title-section,
  .contact-tile,
  .tortoise-tile {
    animation: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--ctp-base-92);
    transition: none;
    opacity: 1;
  }

  .tagline {
    opacity: 0.65;
    height: auto;
    overflow: visible;
    margin-top: 8px;
    animation: none !important;
  }

  .tortoise-tile:hover,
  .contact-tile:hover {
    transform: none;
  }

  .tortoise-tile:hover .tortoise-icon {
    animation: none;
  }

  .cursor {
    animation: none;
  }

  .canvas-hint {
    display: none;
  }
}
