/* ============================================================
   base.css
   Cael — Design System Foundation
   Variables, reset, typography, utilities
   Mobile-first throughout
   ============================================================ */


/* ── Custom Properties ── */

:root {

  /* Colours */
  --paper:        #f5f2ec;
  --paper-dark:   #ede9e1;
  --ink:          #1a1814;
  --ink-soft:     #3d3830;
  --warm-mid:     #c8b89a;
  --warm-light:   #e8e0d4;
  --accent:       #7a6855;
  --accent-soft:  #a08060;
  --muted:        #8a7d6e;

  /* Mood colours — used on check-in and dashboard */
  --mood-1:       #b85c4a;   /* struggling — warm red */
  --mood-2:       #c4875a;   /* low — amber */
  --mood-3:       #a09060;   /* okay — warm neutral */
  --mood-4:       #6a8f70;   /* good — sage green */
  --mood-5:       #4a7c8a;   /* great — calm teal */

  /* Status */
  --success:      #4a7c5f;
  --warning:      #c4875a;
  --crisis:       #b85c4a;

  /* Typography */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  /* Type scale */
  --text-xs:      0.7rem;
  --text-sm:      0.82rem;
  --text-base:    1rem;
  --text-md:      1.1rem;
  --text-lg:      1.4rem;
  --text-xl:      2rem;
  --text-2xl:     2.8rem;
  --text-3xl:     4rem;

  /* Spacing */
  --space-1:      0.25rem;
  --space-2:      0.5rem;
  --space-3:      0.75rem;
  --space-4:      1rem;
  --space-5:      1.25rem;
  --space-6:      1.5rem;
  --space-8:      2rem;
  --space-10:     2.5rem;
  --space-12:     3rem;
  --space-16:     4rem;

  /* Layout */
  --max-width:        680px;
  --max-width-narrow: 480px;
  --page-pad:         1.25rem;

  /* Borders */
  --radius-sm:    2px;
  --radius-md:    6px;
  --radius-lg:    12px;
  --radius-full:  100px;

  /* Shadows */
  --shadow-sm:    0 1px 3px rgba(26, 24, 20, 0.06);
  --shadow-md:    0 4px 16px rgba(26, 24, 20, 0.08);
  --shadow-lg:    0 8px 32px rgba(26, 24, 20, 0.12);

  /* Transitions */
  --transition-fast:  0.15s ease;
  --transition-base:  0.25s ease;
  --transition-slow:  0.4s ease;

  /* Z-index scale */
  --z-base:     1;
  --z-above:    10;
  --z-overlay:  100;
  --z-modal:    200;
  --z-toast:    300;

  /* Safe areas for mobile */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}


/* ── Reset ── */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  background-color: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  font-size: var(--text-base);
  line-height: 1.6;
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

input, button, textarea, select {
  font: inherit;
}

p, h1, h2, h3, h4 {
  overflow-wrap: break-word;
}

ul, ol {
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}


/* ── Grain texture ── */
/* Applied to body via pseudo — matches landing page feel */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: var(--z-toast);
  opacity: 0.35;
}


/* ── Typography ── */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 300;
  line-height: 1.1;
  color: var(--ink);
}

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

/* Display — for big emotional moments */
.display {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 300;
  line-height: 1.0;
}

.display-italic {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 300;
  font-style: italic;
  color: var(--accent-soft);
  line-height: 1.0;
}

/* Label — for small caps, eyebrows, section markers */
.label-caps {
  font-size: var(--text-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}

/* Body variants */
.text-muted   { color: var(--muted); }
.text-accent  { color: var(--accent); }
.text-soft    { color: var(--ink-soft); }
.text-sm      { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }

/* Cael's voice — slightly larger, more air */
.cael-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 300;
  line-height: 1.6;
  color: var(--ink-soft);
  font-style: italic;
}


/* ── Layout ── */

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--page-pad);
}

.page-narrow {
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding: 0 var(--page-pad);
}

.page-full {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Centred single-column content */
.content-col {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--page-pad);
}


/* ── Spacing utilities ── */

.mt-2  { margin-top: var(--space-2); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }

.mb-2  { margin-bottom: var(--space-2); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }

.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }


/* ── Flex utilities ── */

.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1       { flex: 1; }


/* ── Divider ── */

.divider {
  width: 40px;
  height: 1px;
  background: var(--warm-mid);
  margin: var(--space-8) 0;
}

.divider-full {
  width: 100%;
  height: 1px;
  background: var(--warm-light);
  margin: var(--space-6) 0;
}


/* ── Animations ── */

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

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

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

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

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* Staggered entrance helpers */
.anim-fade-up { opacity: 0; animation: fadeUp var(--transition-slow) forwards; }
.anim-delay-1 { animation-delay: 0.1s; }
.anim-delay-2 { animation-delay: 0.2s; }
.anim-delay-3 { animation-delay: 0.3s; }
.anim-delay-4 { animation-delay: 0.4s; }
.anim-delay-5 { animation-delay: 0.5s; }


/* ── Loading state ── */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--warm-light) 25%,
    var(--paper-dark) 50%,
    var(--warm-light) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}


/* ── Mood colour utilities ── */
/* Used on check-in dots, dashboard charts, etc */

.mood-1 { color: var(--mood-1); }
.mood-2 { color: var(--mood-2); }
.mood-3 { color: var(--mood-3); }
.mood-4 { color: var(--mood-4); }
.mood-5 { color: var(--mood-5); }

.mood-bg-1 { background-color: var(--mood-1); }
.mood-bg-2 { background-color: var(--mood-2); }
.mood-bg-3 { background-color: var(--mood-3); }
.mood-bg-4 { background-color: var(--mood-4); }
.mood-bg-5 { background-color: var(--mood-5); }


/* ── Accessibility ── */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

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


/* ── Desktop scale-up ── */

@media (min-width: 640px) {
  :root {
    --page-pad: 2rem;
    --text-3xl: 5rem;
  }
}

@media (min-width: 768px) {
  :root {
    --page-pad: 2.5rem;
  }
}
