/* ═══════════════════════════════════════════════════════════════
   NoSaaS.me — Lofi Aesthetic
   Vigaros 16 Palette + Cherry Blossom + Wabi-Sabi
   ═══════════════════════════════════════════════════════════════ */

/* ─── Vigaros 16 Palette ────────────────────────────────────── */
:root {
  --cream:        #f6e5d3;
  --warm-grey:    #c9c1b0;
  --dusty-rose:   #c19e89;
  --grey-brown:   #97867d;
  --mauve-brown:  #7c6664;
  --dark-brown:   #5b4d4c;
  --charcoal:     #393939;
  --near-black:   #252528;
  --true-dark:    #0d1013;
  --sage:         #b3cac9;
  --muted-teal:   #799694;
  --dark-teal:    #556967;
  --brick:        #8d4640;
  --deep-red:     #833735;
  --dark-crimson: #642f2f;
  --darkest-red:  #492622;

  /* Semantic */
  --bg-primary:   var(--near-black);
  --bg-surface:   var(--charcoal);
  --bg-card:      rgba(57, 57, 57, 0.6);
  --text-primary: var(--cream);
  --text-body:    var(--warm-grey);
  --text-muted:   var(--grey-brown);
  --accent:       var(--sage);
  --accent-hover: var(--muted-teal);
  --accent-dark:  var(--dark-teal);
  --danger:       var(--brick);

  /* Typography */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 2rem;
  --space-xl: 4rem;
  --space-2xl: 8rem;

  /* Layout */
  --content-max: 1200px;
  --content-narrow: 800px;

  /* Animation */
  --ease-out-soft: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Scroll progress (set by JS) */
  --scroll-progress: 0%;
}

/* ─── Base Reset ────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg-primary);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  z-index: 0; /* stacking context so negative z-index children render above root bg (Firefox fix) */
}

/* ─── Lofi Background Image ──────────────────────────────────── */
/* Image fills viewport width, scrolls naturally with page content */
body::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* Maintain image aspect ratio: wide=1536/2752, portrait=2400/1792 */
  aspect-ratio: 2752 / 1536;
  min-height: 100vh;
  background-image: url('/images/bg-lofi-wide.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  z-index: -5;
  image-rendering: pixelated;
  transition: background-image 0.5s ease;
}

body.time-night::before {
  background-image: url('/images/bg-lofi-night.png');
}

/* ─── Canvas Layers (behind everything) ─────────────────────── */
.canvas-layer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#canvas-bg  { z-index: -3; opacity: 0; }  /* hidden — pixel art bg replaces gradient */
#canvas-mid { z-index: -2; opacity: 0; }  /* hidden — pixel art bg replaces hills */
#canvas-fg  { z-index: -1; image-rendering: -moz-crisp-edges; image-rendering: pixelated; }

/* ─── Film Grain Overlay ────────────────────────────────────── */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('/textures/grain.png');
  background-size: 128px 128px;
  opacity: 0.03;
  pointer-events: none;
  z-index: 9998;
  /* Static grain — no animation = zero CPU cost */
}

/* Fallback background when WASM is unavailable */
.wasm-fallback {
  background: linear-gradient(
    135deg,
    var(--near-black) 0%,
    var(--charcoal) 30%,
    var(--dark-brown) 60%,
    var(--near-black) 100%
  );
}

/* ─── Scroll Progress Bar ───────────────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: var(--scroll-progress);
  background: linear-gradient(90deg, var(--muted-teal), var(--sage));
  z-index: 9999;
  transition: width 0.1s linear;
}

/* ─── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2.5rem, 5vw, 4rem); font-weight: 700; }
h2 { font-size: clamp(1.8rem, 3.5vw, 2.8rem); font-weight: 700; }
h3 { font-size: clamp(1.3rem, 2.5vw, 1.8rem); font-weight: 400; font-style: italic; }
h4 { font-size: 1.1rem; font-weight: 600; }

p {
  max-width: 65ch;
  margin-bottom: var(--space-md);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s var(--ease-out-soft);
}

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

/* ─── Ink-Stroke Underline ──────────────────────────────────── */
.ink-link {
  position: relative;
  display: inline-block;
}

.ink-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width 0.3s var(--ease-out-soft);
  border-radius: 1px;
}

.ink-link:hover::after,
.ink-link.active::after {
  width: 100%;
}

/* ─── Layout ────────────────────────────────────────────────── */
.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container--narrow {
  max-width: var(--content-narrow);
}

/* ─── Navigation ────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: var(--space-sm) 0;
  background: rgba(13, 16, 19, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(179, 202, 201, 0.06);
}

.nav > .container,
.nav > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.nav__logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.6rem;
  color: var(--cream);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.15em;
}

.nav__logo span,
.nav__logo .accent {
  color: var(--sage);
  font-style: italic;
}

.nav__links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
  align-items: center;
}

.nav__link {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--grey-brown);
  transition: color 0.25s ease;
  padding: 0.4rem 0;
}

.nav__link:hover {
  color: var(--cream);
}

.nav__link.active {
  color: var(--sage);
  border-bottom: 1.5px solid var(--sage);
}

/* Mobile nav */
.nav__hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
}

.nav__hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  margin: 5px 0;
  transition: transform 0.3s ease;
}

@media (max-width: 768px) {
  .nav__hamburger { display: block; }
  .nav__links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: rgba(37, 37, 40, 0.95);
    backdrop-filter: blur(16px);
    padding: var(--space-lg);
    gap: var(--space-md);
  }
  .nav__links.open { display: flex; }
}

/* ─── Hero Section ──────────────────────────────────────────── */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  position: relative;
}

.hero__content {
  text-align: center;
  max-width: 1100px;
  z-index: 1;
  padding: var(--space-xl) var(--space-lg);
}

.hero__glass {
  background: rgba(13, 16, 19, 0.18);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  border-radius: 20px;
  border: 1px solid rgba(179, 202, 201, 0.04);
  padding: var(--space-lg) var(--space-xl);
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, black 50%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, black 50%, transparent 100%);
}

.hero__title {
  color: var(--cream);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 30px rgba(13,16,19,0.3);
  white-space: nowrap;
  font-size: clamp(1.4rem, 3.8vw, 3.5rem);
  margin-bottom: var(--space-md);
}

.hero__title em {
  font-style: normal;
  color: var(--sage);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 20px rgba(179,202,201,0.2);
}

.hero__subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--warm-grey);
  margin-bottom: var(--space-xl);
  font-weight: 400;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.hero__ctas {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.8rem 1.8rem;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: all 0.2s var(--ease-out-soft);
  border: none;
  cursor: pointer;
}

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

.btn--primary:hover {
  background: var(--accent-hover);
  color: var(--true-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(179, 202, 201, 0.2);
}

.btn--primary:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn--outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--text-muted);
}

.btn--outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn--outline:active {
  transform: translateY(1px);
}

/* ─── Phone Mockup ──────────────────────────────────────────── */
.phone-mockup {
  position: relative;
  width: 280px;
  margin: var(--space-xl) auto;
  perspective: 800px;
  transition: transform 0.1s linear;
}

.phone-mockup__frame {
  background: var(--charcoal);
  border-radius: 36px;
  padding: 12px;
  box-shadow:
    0 0 60px rgba(179, 202, 201, 0.15),
    0 20px 60px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(179, 202, 201, 0.1);
}

.phone-mockup__screen {
  width: 100%;
  aspect-ratio: 9/19.5;
  background: linear-gradient(135deg, var(--near-black), var(--charcoal));
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.phone-mockup__screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.phone-mockup__notch {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 24px;
  background: var(--charcoal);
  border-radius: 12px;
}

.phone-mockup__glow {
  position: absolute;
  inset: -20px;
  background: radial-gradient(ellipse at center, rgba(179, 202, 201, 0.12), transparent 70%);
  z-index: -1;
  pointer-events: none;
}

/* ─── Product Cards ─────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-xl) 0;
}

.product-card {
  background: var(--bg-card);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(179, 202, 201, 0.08);
  transition: transform 0.15s linear, box-shadow 0.2s var(--ease-out-soft);
  transform-style: preserve-3d;
  perspective: 800px;
  backdrop-filter: blur(8px);
}

.product-card:hover {
  box-shadow:
    0 8px 30px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(179, 202, 201, 0.15);
}

.product-card__image {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  border-bottom: 1px solid rgba(179, 202, 201, 0.05);
}

.product-card__body {
  padding: var(--space-lg);
}

.product-card__title {
  font-size: 1.3rem;
  margin-bottom: var(--space-sm);
}

.product-card__tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: var(--space-md);
}

.product-card__price {
  display: inline-block;
  background: rgba(179, 202, 201, 0.1);
  color: var(--accent);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.product-card__tags {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.product-card__tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(179, 202, 201, 0.08);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── Cassette Player ───────────────────────────────────────── */
.cassette {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  width: 120px;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out-soft);
}

.cassette:hover {
  transform: scale(1.05) rotate(-2deg);
}

.cassette__body {
  background: var(--charcoal);
  border-radius: 8px;
  padding: 10px;
  border: 1px solid rgba(179, 202, 201, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.cassette__window {
  background: rgba(13, 16, 19, 0.6);
  border-radius: 4px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.cassette__reel {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  position: relative;
}

.cassette__reel::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.cassette__reel.spinning {
  animation: spin 2s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

.cassette__label {
  text-align: center;
  font-size: 0.5rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-family: var(--font-body);
}

.cassette__status {
  font-size: 0.45rem;
  color: var(--accent);
  text-align: center;
  margin-top: 2px;
  opacity: 0.7;
}

/* ─── Scroll Reveal Animations ──────────────────────────────── */
.scroll-reveal {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.7s var(--ease-out-soft), transform 0.7s var(--ease-out-soft);
}

/* Staggered children */
.scroll-reveal.visible > *:nth-child(1) { transition-delay: 0.05s; }
.scroll-reveal.visible > *:nth-child(2) { transition-delay: 0.1s; }
.scroll-reveal.visible > *:nth-child(3) { transition-delay: 0.15s; }
.scroll-reveal.visible > *:nth-child(4) { transition-delay: 0.2s; }
.scroll-reveal.visible > *:nth-child(5) { transition-delay: 0.25s; }

/* Typewriter header variant */
.typewriter {
  overflow: hidden;
}

.typewriter.visible .typewriter__text {
  animation: typewrite 0.8s steps(30) forwards;
}

@keyframes typewrite {
  from { max-width: 0; }
  to { max-width: 100%; }
}

.typewriter__text {
  display: inline-block;
  max-width: 0;
  white-space: nowrap;
  overflow: hidden;
  border-right: 2px solid var(--accent);
  animation: blink-cursor 0.7s step-end infinite;
}

@keyframes blink-cursor {
  50% { border-color: transparent; }
}

/* ─── Section Styles ────────────────────────────────────────── */
.section {
  padding: var(--space-2xl) var(--space-lg);
}

/* Compact glass sections so they fit within the wallpaper image */
.section--glass {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-lg);
}

/* Glass pane for sections overlapping the wallpaper */
.section--glass > .container {
  background: rgba(13, 16, 19, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 16px;
  border: 1px solid rgba(179, 202, 201, 0.06);
  padding: var(--space-xl) var(--space-lg);
}

.section__title {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.section__subtitle {
  text-align: center;
  color: var(--text-muted);
  max-width: 50ch;
  margin: 0 auto var(--space-xl);
}

/* ─── Values Grid (Mission Page) ────────────────────────────── */
.values-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-lg);
}

.value-card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: var(--space-lg);
  border: 1px solid rgba(179, 202, 201, 0.05);
  backdrop-filter: blur(4px);
  transition: border-color 0.3s ease;
}

.value-card:hover {
  border-color: rgba(179, 202, 201, 0.15);
}

.value-card__icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-md);
  color: var(--accent);
}

.value-card__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.value-card__desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ─── Blog List ─────────────────────────────────────────────── */
.blog-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.blog-entry {
  padding: var(--space-lg);
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid rgba(179, 202, 201, 0.05);
  transition: border-color 0.3s ease;
}

.blog-entry:hover {
  border-color: rgba(179, 202, 201, 0.15);
}

.blog-entry__date {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

.blog-entry__title {
  font-size: 1.3rem;
  margin-bottom: var(--space-sm);
}

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

/* ─── Footer ────────────────────────────────────────────────── */
.footer {
  padding: var(--space-xl) var(--space-lg);
  border-top: 1px solid rgba(179, 202, 201, 0.08);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

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

/* ─── Page Transitions ──────────────────────────────────────── */
.page-enter {
  animation: pageIn 0.35s var(--ease-out-soft) forwards;
}

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

/* ─── 404 Page ──────────────────────────────────────────────── */
.not-found {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.not-found__code {
  font-family: var(--font-display);
  font-size: 8rem;
  color: var(--charcoal);
  line-height: 1;
}

/* ─── Admin ─────────────────────────────────────────────────── */
.login-form {
  max-width: 400px;
  margin: 0 auto;
  padding: var(--space-xl);
}

.form-field {
  margin-bottom: var(--space-md);
}

.form-field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  background: rgba(13, 16, 19, 0.5);
  border: 1px solid rgba(179, 202, 201, 0.1);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(179, 202, 201, 0.1);
}

/* ─── Reduced Motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .scroll-reveal {
    opacity: 1;
    transform: none;
  }

  body::after {
    animation: none;
  }
}
