/* =========================================================
   ENAMA APPS — Design System "Midnight Studio"
   Concept: a near-black gallery room where whisper-weight
   serif headlines and a few chromatic tiles (one per app
   moment — practice, streaks, certification, scripture)
   are the only color. Flat surfaces, no shadows — elevation
   is a color step, not a blur.
   Layered tokens: primitive -> semantic -> component.
   No build step: plain CSS custom properties only.
   ========================================================= */

/* ---------- 1. PRIMITIVE TOKENS ---------- */
:root {
  /* Neutrals — dark gallery canvas */
  --obsidian:  #0f1011;
  --abyss:     #090a0b;
  --graphite:  #2e2e2e;
  --steel:     #3f4041;
  --silver:    #cacaca;
  --fog:       #6a6b6b;
  --ash:       #9f9fa0;
  --cloud:     #f5f5f7;
  --pure:      #ffffff;
  --void:      #000000;

  /* Chromatic — one per app moment, used only on tiles/chips */
  --iris:      #847dff; /* practice + AI feedback */
  --iris-pale: #d1c9ff;
  --iris-deep: #4b49aa;
  --cyan:      #00b3dd; /* progress / streaks */
  --orchid:    #dd90d8; /* scripture app, coming soon */
  --periwinkle:#90b8f0; /* B2 First certification */

  /* Feedback (kept out of the chromatic set on purpose) */
  --red-600: #c94a3f;
  --red-50:  #2a1615;
  --green-600: #4fae7d;
  --green-50: #10201a;

  /* Type scale (DESIGN.md scale, clamped for mobile) */
  --text-mono-label: 0.75rem;   /* 12px */
  --text-sm: 0.875rem;          /* 14px */
  --text-base: 1rem;            /* 16px */
  --text-md: 1.125rem;          /* 18px */
  --text-heading: clamp(1.75rem, 1.4rem + 1.6vw, 2.375rem);   /* 38px */
  --text-display-sm: clamp(2.5rem, 1.9rem + 2.8vw, 5rem);     /* 80px */
  --text-display: clamp(2.75rem, 2rem + 3.6vw, 6rem);         /* 96px */

  /* Space scale — base unit 4px */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Radius */
  --radius-input: 8px;
  --radius-card: 16px;
  --radius-tile: 30px;
  --radius-pill: 9999px;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-fast: 150ms;
  --duration-base: 250ms;
}

/* ---------- 2. SEMANTIC TOKENS ---------- */
:root {
  --color-bg: var(--obsidian);
  --color-bg-alt: var(--abyss);
  --color-surface: var(--graphite);
  --color-surface-hover: var(--steel);
  --color-border: rgba(255, 255, 255, 0.1);
  --color-border-strong: rgba(255, 255, 255, 0.22);

  --color-text-primary: var(--cloud);
  --color-text-secondary: var(--ash);
  --color-text-muted: var(--fog);
  --color-text-on-accent: var(--void);
  --color-text-loud: var(--pure);

  --color-accent: var(--iris);
  --color-accent-soft: rgba(132, 125, 255, 0.14);
  --color-accent-border: rgba(132, 125, 255, 0.4);

  --color-danger: var(--red-600);
  --color-danger-bg: var(--red-50);
  --color-success: var(--green-600);
  --color-success-bg: var(--green-50);

  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Roboto Mono', 'SFMono-Regular', Consolas, monospace;

  --content-max-width: 1200px;
  --content-max-width-narrow: 680px;
}

/* ---------- 3. BASE / RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  color-scheme: dark;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text-secondary);
  background: var(--color-bg);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 300;
  line-height: 0.98;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-4);
  color: var(--color-text-primary);
}

h1 { font-size: var(--text-display-sm); font-optical-sizing: auto; }
h2 { font-size: var(--text-heading); }
h3 { font-size: var(--text-md); font-weight: 400; }

p { margin: 0 0 var(--space-4); color: var(--color-text-secondary); max-width: 62ch; }

a {
  color: var(--pure);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { color: var(--iris-pale); }

img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--pure);
  outline-offset: 2px;
}

ul, ol { padding-left: 1.25rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  background: var(--pure);
  color: var(--void);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-input);
  z-index: 100;
}
.skip-link:focus {
  left: var(--space-4);
  top: var(--space-4);
}

/* Grain — a barely-there texture so flat dark fields feel like a material */
.has-grain { position: relative; }
.has-grain::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 3px 3px;
}

/* ---------- 4. LAYOUT ---------- */
.container {
  width: 100%;
  max-width: var(--content-max-width);
  margin-inline: auto;
  padding-inline: var(--space-6);
  position: relative;
}

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

.section { padding-block: var(--space-20); position: relative; }
.section--alt { background: var(--color-bg-alt); }
.section--ink {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.stack { display: flex; flex-direction: column; gap: var(--space-4); }

.grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 768px) {
  .grid--3, .grid--2 { grid-template-columns: 1fr; }
  h1 { font-size: clamp(2.25rem, 1.8rem + 3vw, 3rem); }
  .section { padding-block: var(--space-12); }
}

/* ---------- 5. COMPONENTS ---------- */

/* Site header / nav — sticky glass over the dark canvas */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 16, 17, 0.72);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--color-border);
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pure);
  text-decoration: none;
}

.brand:hover { color: var(--pure); }

.brand__mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: var(--iris);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-6);
}

.main-nav__list {
  display: flex;
  gap: var(--space-6);
  list-style: none;
  margin: 0;
  padding: 0;
}

.main-nav a {
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
}

.main-nav a:hover { color: var(--pure); }

.lang-switch {
  display: flex;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.lang-switch a {
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
}

.lang-switch a[aria-current="true"] {
  color: var(--void);
  background: var(--pure);
}

@media (max-width: 768px) {
  .site-header__bar {
    flex-wrap: wrap;
    row-gap: var(--space-3);
  }
  .main-nav {
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
    border-radius: var(--radius-card);
    padding: var(--space-4);
  }
  .main-nav__list { flex-direction: column; gap: var(--space-3); }
  .lang-switch { align-self: flex-start; }
}

/* Buttons / CTA */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-input);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 44px;
  transition: background var(--duration-base) var(--ease), color var(--duration-base) var(--ease), border-color var(--duration-base) var(--ease);
}

.btn--primary {
  background: var(--pure);
  color: var(--void);
}
.btn--primary:hover { background: var(--cloud); color: var(--void); }
.btn--primary::after {
  content: "→";
  margin-left: var(--space-1);
}

.btn--secondary {
  background: transparent;
  color: var(--pure);
  border-color: var(--color-border-strong);
}
.btn--secondary:hover { border-color: var(--pure); color: var(--pure); background: rgba(255, 255, 255, 0.06); }

/* Hero */
.hero { padding-block: var(--space-20) var(--space-16); }

.hero--dark { position: relative; color: var(--pure); }

.hero--dark .hero__subtitle { color: var(--color-text-secondary); }
.hero--dark .hero__title { color: var(--color-text-loud); }

.hero__grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-16);
  align-items: center;
}

.hero__title { max-width: 14ch; }

.hero__subtitle {
  font-size: var(--text-md);
  max-width: 46ch;
  margin-bottom: var(--space-8);
}

.hero__actions { display: flex; gap: var(--space-4); flex-wrap: wrap; }

@media (max-width: 900px) {
  .hero__grid { grid-template-columns: 1fr; }
  .hero-card-stack { order: -1; max-width: 360px; margin-inline: auto; }
}

/* Hero visual — three flat chromatic tiles: the app's real moments
   (a scripture teaser, a certification badge, a live AI correction).
   Flat fills, 30px radius, no blur, no shadow — per the Do's/Don'ts. */
.hero-card-stack {
  position: relative;
  margin-inline: auto;
  max-width: 340px;
  padding: var(--space-6) 0;
}

.hero-card__card {
  position: relative;
  border-radius: var(--radius-tile);
  padding: var(--space-6) var(--space-5);
  color: var(--void);
}

.hero-card--bible .hero-card__card { background: var(--orchid); }
.hero-card--cert .hero-card__card { background: var(--periwinkle); }

.hero-card__label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.6);
  margin-bottom: var(--space-3);
}

.hero-card__line {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-md);
  color: var(--void);
  line-height: 1.35;
  margin: 0 0 var(--space-2);
}

.hero-card__ref {
  font-size: var(--text-sm);
  color: rgba(0, 0, 0, 0.55);
}

.hero-card__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--void);
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  margin-top: var(--space-3);
}

.hero-card__icon {
  width: 22px;
  height: 22px;
  color: var(--void);
  margin-bottom: var(--space-3);
}

.hero-card--back {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-card--bible { transform: rotate(-4deg) translate(-14px, 10px); }
.hero-card--cert { transform: rotate(4deg) translate(14px, -8px); }

@media (max-width: 900px) {
  .hero-card--bible { transform: rotate(-3deg) translate(-8px, 6px); }
  .hero-card--cert { transform: rotate(3deg) translate(8px, -6px); }
}

/* Hero visual — the one bold moment: a live AI writing correction */
.correction-card {
  position: relative;
  z-index: 1;
  margin-inline: auto;
  max-width: 340px;
}

.correction-card__card {
  position: relative;
  z-index: 1;
  background: var(--iris);
  border-radius: var(--radius-tile);
  padding: var(--space-8) var(--space-6);
  color: var(--void);
}

.correction-card__label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.6);
  margin-bottom: var(--space-4);
}

.correction-card__line {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-md);
  color: var(--void);
  line-height: 1.4;
  margin: 0 0 var(--space-6);
}

.correction-card__strike {
  position: relative;
  color: rgba(0, 0, 0, 0.4);
}
.correction-card__strike::after {
  content: "";
  position: absolute;
  left: -2%;
  right: -2%;
  top: 52%;
  height: 2px;
  background: var(--void);
  transform: scaleX(0);
  transform-origin: left;
  animation: draw-strike 700ms var(--ease) 400ms forwards;
}

.correction-card__fix {
  color: var(--void);
  text-decoration: underline;
  text-decoration-color: var(--void);
  text-underline-offset: 4px;
  font-weight: 600;
  opacity: 0;
  animation: fade-in 400ms var(--ease) 900ms forwards;
}

.correction-card__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--void);
  background: rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  opacity: 0;
  animation: fade-in 400ms var(--ease) 1200ms forwards;
}

@keyframes draw-strike {
  to { transform: scaleX(1); }
}
@keyframes fade-in {
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .correction-card__strike::after,
  .correction-card__fix,
  .correction-card__badge {
    animation: none;
    transform: none;
    opacity: 1;
  }
}

/* Value cards */
.value-card {
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.value-card__icon {
  width: 28px;
  height: 28px;
  margin-bottom: var(--space-4);
  color: var(--iris);
}

.value-card h3 { margin-bottom: var(--space-2); color: var(--color-text-primary); }
.value-card p { margin: 0; }

/* App card (catalog) */
.app-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-8);
  background: var(--color-surface);
  border: 1px solid transparent;
  border-radius: var(--radius-tile);
  text-decoration: none;
  transition: background var(--duration-base) var(--ease);
}

.app-card:hover { background: var(--color-surface-hover); }

.app-card__category {
  display: inline-block;
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--iris-pale);
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent-border);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  margin-bottom: var(--space-4);
}

.app-card h3 { color: var(--color-text-primary); margin-bottom: var(--space-2); font-weight: 400; }
.app-card p { margin: 0; }

/* App detail */
.app-detail__header { padding-block: var(--space-16) var(--space-4); }
.app-detail__header + .section { padding-top: var(--space-8); }
.app-detail__tagline { font-size: var(--text-md); color: var(--color-text-secondary); }

.app-detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin: var(--space-8) 0;
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-3);
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  border-radius: var(--radius-card);
}

.feature-list__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--cyan);
  margin-top: 2px;
}

/* Founder-note card — the single deliberate use of the inverted
   light surface, reserved for the About page. */
.founder-note {
  background: var(--silver);
  color: var(--void);
  border-radius: var(--radius-tile);
  padding: var(--space-8);
  margin: var(--space-8) 0;
}
.founder-note p { color: rgba(0, 0, 0, 0.7); margin: 0; }
.founder-note p + p { margin-top: var(--space-4); }
.founder-note a { color: var(--void); text-decoration-color: var(--iris-deep); }
.founder-note a:hover { color: var(--iris-deep); }

/* Legal content */
.prose { max-width: var(--content-max-width-narrow); }
.prose h2 { margin-top: var(--space-12); }
.prose ul { color: var(--color-text-secondary); }

.placeholder-notice {
  background: var(--color-accent-soft);
  border-left: 2px solid var(--iris);
  border-radius: var(--radius-input);
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  margin-bottom: var(--space-8);
}
.placeholder-notice::before {
  content: "DRAFT";
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--iris-pale);
  margin-bottom: var(--space-2);
}
html[lang="es"] .placeholder-notice::before { content: "BORRADOR"; }

/* Contact form — reuses the system's dark input treatment */
.form-field { margin-bottom: var(--space-6); }

.form-field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  font: inherit;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  background: var(--void);
  color: var(--cloud);
  min-height: 44px;
}

.form-field textarea { min-height: 140px; resize: vertical; }

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: 2px solid var(--pure);
  outline-offset: 1px;
  border-color: var(--pure);
}

/* Footer */
.site-footer {
  background: var(--color-bg-alt);
  color: var(--color-text-secondary);
  padding-block: var(--space-12);
  margin-top: var(--space-20);
}

.site-footer__grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
  justify-content: space-between;
  margin-bottom: var(--space-8);
}

.site-footer__brand {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pure);
  margin: 0 0 var(--space-2);
}

.site-footer__grid p { color: var(--color-text-muted); }

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-8);
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-footer a {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  text-decoration: none;
}
.site-footer a:hover { color: var(--pure); }

.site-footer__meta {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-6);
}

/* 404 */
.error-page {
  padding-block: var(--space-20);
  text-align: center;
}

.error-page__code {
  display: block;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: var(--text-display);
  line-height: 0.9;
  color: var(--iris);
  margin-bottom: var(--space-4);
}

/* Utility */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
