/**
 * The Ultimate Journey — Web Companion
 * Theme: dark background, gold accent, Cormorant Garamond display —
 * matching the existing *SELF / 42self.xyz / workbook brand identity.
 * This is deliberately the SAME visual language as the PDF and
 * 42self.xyz, not a new design system for the app.
 */

:root {
  /* BACKGROUND */
  --color-bg: #0a0a0f;
  --color-bg-raised: #12121a;       /* cards, input backgrounds */
  --color-bg-raised-hover: #181820;

  /* TEXT */
  --color-text-primary: #e8e6e1;
  --color-text-secondary: #9a9a9a;  /* muted body copy */
  --color-text-faint: #6a6a6a;      /* timestamps, tertiary labels */

  /* ACCENT — gold, matches the workbook and 42self.xyz */
  --color-accent: #d4af37;
  --color-accent-dim: #8b7328;
  --color-accent-soft: rgba(212, 175, 55, 0.12); /* backgrounds behind gold text */

  /* BORDERS */
  --color-border: #2a2a35;
  --color-border-accent: rgba(212, 175, 55, 0.35);

  /* STATUS */
  --color-error: #d47373;

  /* TYPE */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'EB Garamond', Georgia, serif;
  --font-ui: -apple-system, 'Segoe UI', sans-serif; /* buttons, labels — quiet, doesn't compete */

  --fs-xs: 0.8rem;
  --fs-sm: 0.95rem;
  --fs-base: 1.125rem;
  --fs-lg: 1.4rem;
  --fs-xl: 1.9rem;
  --fs-2xl: 2.6rem;

  --line-tight: 1.3;
  --line-base: 1.7;
  --line-relaxed: 1.9;

  /* SPACING */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.75rem;
  --space-lg: 2.75rem;
  --space-xl: 4.5rem;

  --radius: 6px;
  --transition: 220ms ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--line-base);
  min-height: 100vh;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  color: var(--color-accent);
  font-weight: 500;
  line-height: var(--line-tight);
  margin: 0 0 var(--space-sm) 0;
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

p { margin: 0 0 var(--space-sm) 0; color: var(--color-text-primary); }

.muted { color: var(--color-text-secondary); }
.faint { color: var(--color-text-faint); font-size: var(--fs-xs); }

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- layout shell ---- */
.shell {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.shell--top {
  justify-content: flex-start;
}

/* ---- form elements ---- */
label {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

input[type="email"],
input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  padding: 0.85rem 1rem;
  transition: border-color var(--transition);
}

textarea {
  min-height: 140px;
  resize: vertical;
  line-height: var(--line-relaxed);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* visible keyboard focus everywhere, not just inputs */
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

button {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  letter-spacing: 0.02em;
  border-radius: var(--radius);
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
  border: none;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-bg);
  font-weight: 600;
}
.btn-primary:hover { background: var(--color-accent-dim); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.btn-quiet {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.btn-quiet:hover { border-color: var(--color-accent-dim); color: var(--color-text-primary); }

.error-message {
  color: var(--color-error);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  margin-top: var(--space-xs);
  min-height: 1.2em;
}

/* ---- save status indicator (used on the check-in screen) ---- */
.save-status {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
  min-height: 1.2em;
  transition: opacity var(--transition);
}
.save-status.saved { color: var(--color-accent-dim); }

/* ---- progress / return screen ---- */
.progress-line {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--color-text-secondary);
  font-size: var(--fs-base);
  margin-bottom: var(--space-md);
}

.stage-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}
.stage-row:last-child { border-bottom: none; }

.stage-row .stage-title { font-family: var(--font-display); font-size: var(--fs-lg); color: var(--color-text-primary); }
.stage-row .stage-status { font-family: var(--font-ui); font-size: var(--fs-xs); color: var(--color-text-faint); }
.stage-row.complete .stage-status { color: var(--color-accent-dim); }

/* ---- the anchor / return moment: deliberately bare ---- */
.anchor-screen {
  text-align: center;
}
.anchor-screen .anchor-question {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  color: var(--color-text-primary);
  margin-bottom: var(--space-lg);
}
.anchor-screen textarea {
  text-align: left;
}

.pause {
  opacity: 0;
  animation: fade-in 1.2s ease forwards;
  animation-delay: 0.3s;
}
@keyframes fade-in { to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .pause { animation: none; opacity: 1; }
}

/* ---- LIGHT THEME ----
   Same palette as 42self.xyz's light mode, so switching between the
   website and the companion app doesn't feel like two different brands. */
[data-theme="light"] {
  --color-bg: #faf8f3;
  --color-bg-raised: #ede6d0;
  --color-bg-raised-hover: #e3dac0;

  --color-text-primary: #1a1208;
  --color-text-secondary: #3d2e10;
  --color-text-faint: #5a4a2a;

  --color-accent: #7a5e0e;
  --color-accent-dim: #5e480b;
  --color-accent-soft: rgba(122, 94, 14, 0.1);

  --color-border: rgba(0, 0, 0, 0.12);
  --color-border-accent: rgba(122, 94, 14, 0.35);

  --color-error: #a63d3d;
}

/* ---- theme toggle — small fixed corner button on every screen ---- */
.theme-toggle-fixed {
  position: fixed;
  top: 14px;
  right: 14px;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 50;
}
.theme-toggle-fixed:hover {
  border-color: var(--color-accent-dim);
  color: var(--color-text-primary);
}

/* ---- the Return moment: Day 1 vs. now, side by side ---- */
.return-compare {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}
.return-compare .then-now-block {
  border-left: 2px solid var(--color-border);
  padding-left: var(--space-sm);
}
.return-compare .then-now-label {
  font-family: var(--font-ui);
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: var(--space-xs);
}
.return-compare .then-now-answer {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--color-text-primary);
  font-size: var(--fs-base);
  line-height: var(--line-relaxed);
}
.return-compare .then-now-block.now {
  border-left-color: var(--color-accent-dim);
}
.return-compare .then-now-block.now .then-now-answer {
  font-style: normal;
  color: var(--color-accent);
}
