/* ==========================================================================
   wavefunk.io — Main Stylesheet
   Earendil-inspired: full-viewport canvas, overlay content, corner chrome
   ========================================================================== */

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

:root {
  --mono: 'Hack', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --font-mono: var(--mono);
  --color-accent: #7b93db;
  --color-bg: #0a0a12;
  --color-text: rgba(255, 255, 255, 0.9);
  --color-text-muted: rgba(255, 255, 255, 0.5);
  --color-overlay-bg: rgba(10, 10, 18, 0.85);
  --color-fullpage-bg: rgba(10, 10, 18, 0.95);
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-hover: rgba(255, 255, 255, 0.2);
  --chrome-inset: 60px;
}

html, body {
  background: var(--color-bg);
  font-family: var(--mono);
  color: var(--color-text);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

body.has-overlay { overflow: hidden; }
body.has-full-page { overflow-y: auto; height: auto; }

a { color: var(--color-text); text-decoration: none; }
a:hover { color: #fff; }

/* --- Z-0: Canvas Background --- */
#webgl-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 0;
}

/* --- Z-10: Center Logo --- */
.center-logo {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  text-decoration: none;
}

.center-logo__img {
  width: 120px;
  opacity: 0.9;
  display: block;
  margin: 0 auto;
}

.center-logo__wordmark {
  display: block;
  margin-top: 16px;
  font: 14px/1 var(--mono);
  letter-spacing: 0.35em;
  color: var(--color-text);
  text-transform: uppercase;
}

/* --- Z-100: Page Content --- */
.page {
  position: relative;
  z-index: 100;
}

/* --- Overlay --- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 80px 30px;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.overlay.is-open { opacity: 1; }

.overlay__panel {
  position: relative;
  width: min(900px, 92vw);
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  padding: 48px;
  background: var(--color-overlay-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  font-size: 15px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.overlay.is-open .overlay__panel {
  opacity: 1;
  transform: translateY(0);
}

.overlay__dismiss {
  position: absolute;
  top: 18px; right: 18px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font: 1.4em/1 var(--mono);
  cursor: pointer;
  z-index: 5;
  padding: 4px 8px;
}

.overlay__dismiss:hover { color: #fff; }

.overlay__title {
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.overlay__subtitle {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

/* --- Full Page Content --- */
.full-page {
  min-height: 100vh;
  background: var(--color-fullpage-bg);
  padding: 80px 30px 60px;
  overflow-y: auto;
}

.full-page__inner {
  max-width: 800px;
  margin: 0 auto;
}

.full-page__title {
  font-size: 1.3rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.full-page__subtitle {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

/* --- Z-200: Navigation --- */
.top-nav {
  position: fixed;
  top: var(--chrome-inset);
  right: var(--chrome-inset);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.menu-trigger {
  appearance: none;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  cursor: pointer;
  padding: 0;
}

.menu-label {
  font: 14px/1 var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text);
  transition: opacity 0.2s;
}

.top-nav.is-open .menu-label { opacity: 0; visibility: hidden; }

.menu-chevron {
  font: 20px/1 var(--mono);
  color: rgba(255, 255, 255, 0.45);
  transition: transform 0.25s ease, color 0.25s ease;
  animation: chevronPulse 1.1s ease-in-out infinite alternate;
}

.menu-trigger:hover .menu-label,
.menu-trigger:hover .menu-chevron { color: #fff; animation: none; }

.top-nav.is-open .menu-chevron {
  animation: none;
  transform: rotate(90deg);
  color: var(--color-text);
}

@keyframes chevronPulse {
  from { color: rgba(160, 160, 160, 0.6); }
  to { color: rgba(255, 255, 255, 0.95); }
}

.menu-links {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.menu-links[hidden] { display: none; }

.nav-link {
  font: 14px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s;
}

.nav-link:hover { color: #fff; }

/* --- Z-200: Footer --- */
.site-footer {
  position: fixed;
  bottom: var(--chrome-inset);
  left: var(--chrome-inset);
  z-index: 200;
  font: 14px/1 var(--mono);
  color: var(--color-text);
}

/* --- Card Grid --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  display: block;
  padding: 1.2rem;
  border: 1px solid var(--color-border);
  transition: border-color 0.2s;
  text-decoration: none;
  color: var(--color-text);
}

.card:hover { border-color: var(--color-border-hover); }

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.card__name { font-size: 0.95rem; font-weight: 700; }

.card__badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  padding: 2px 6px;
}

.card__tagline,
.card__description {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* --- Contact --- */
.contact__intro { margin-bottom: 2rem; line-height: 1.7; }

.contact__email-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.contact__email a { font-size: 1rem; color: var(--color-text); }
.contact__email a:hover { color: #fff; }

/* --- Blog list --- */
.blog-list { list-style: none; }

.blog-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
}

.blog-list li:last-child { border-bottom: none; }

.blog-list__title { font-weight: 700; margin-bottom: 4px; }

.blog-list__meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* --- Tool drawers --- */
.tool-drawer {
  border: 1px solid var(--color-border);
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.tool-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  font: 0.9rem/1.4 var(--mono);
  color: var(--color-text);
  text-align: left;
}

.tool-drawer-header:hover { color: #fff; }

.tool-drawer-body { padding: 0 1rem 1rem; display: none; }
.tool-drawer.is-open .tool-drawer-body { display: block; }

/* --- Utility --- */
.empty-state {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 2rem 0;
}

/* --- Print --- */
@media print {
  #webgl-bg, .top-nav, .site-footer, .center-logo { display: none; }
}

/* --- Responsive: Tablet --- */
@media (max-width: 800px) {
  :root { --chrome-inset: 40px; }
  .overlay { padding: 60px 60px 60px 16px; }
  .overlay__panel { width: min(96vw, calc(100vw - 80px)); padding: 24px 16px; max-height: calc(100vh - 120px); }
  .center-logo__img { width: 90px; }
}

/* --- Responsive: Mobile --- */
@media (max-width: 520px) {
  :root { --chrome-inset: 28px; }
  .overlay {
    padding: 56px 8px 28px 8px;
    justify-content: flex-start;
  }
  .overlay__panel {
    width: min(65vw, calc(100vw - 130px));
    padding: 16px 12px;
    max-height: calc(100vh - 84px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .center-logo__img { width: 70px; }
  .card-grid { grid-template-columns: 1fr; }

  /* Tap targets: all interactive elements 44px minimum */
  .menu-trigger { padding: 12px 0; min-height: 44px; }
  .nav-link { padding: 12px 0; display: block; }
  .menu-links { gap: 0; }
  .overlay__dismiss { padding: 10px 12px; min-height: 44px; min-width: 44px; }
  .contact__email a { display: inline-block; padding: 12px 0; }
  .blog-list a { display: block; padding: 8px 0; }
  .card { padding: 1rem; }

  /* Scroll indicator on overlay panels */
  .overlay__panel {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
  }
  .overlay__panel::-webkit-scrollbar { width: 4px; }
  .overlay__panel::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
  }
  .overlay__panel::-webkit-scrollbar-track { background: transparent; }
}
