/* ============================================================
   Dr Logbook Design Tokens - v4 (Pine Teal + Liquid Glass)

   Source of truth for all colors, spacing primitives, shadows,
   radii, and the font stack. Light tokens live in :root; dark
   tokens override under [data-theme="dark"] and (when no user
   preference is set) under @media (prefers-color-scheme: dark).

   IMPORTANT: New components must reference these variables -
   never hardcode hex. Old components (PageLayout, IOSCard*) use
   hardcoded colors and will only honor light mode until migrated.
   ============================================================ */

:root {
  /* ----- Surfaces / Neutrals (cool gray) ----- */
  --bg: #f6f7f8;
  --bg-grain: #eef0f2;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-soft: #eef0f2;

  /* ----- Brand: Pine Teal ----- */
  --teal: #0f766e;
  --teal-deep: #0b5951;
  --teal-2: #14857b;
  --teal-soft: #ccfbf1;
  --teal-tint: #e6f7f4;
  --teal-mist: #f0faf7;

  /* ----- Semantic ----- */
  --amber: #d97706;
  --amber-deep: #92400e;
  --amber-soft: #fef3c7;
  --green: #059669;
  --green-deep: #065f46;
  --green-soft: #d1fae5;
  --red: #dc2626;
  --red-deep: #991b1b;
  --red-soft: #fee2e2;
  --slate: #334155;

  /* ----- Sidebar (always dark, rarely overridden) ----- */
  --sidebar: #0c1220;
  --sidebar-ink: #e5e7eb;

  /* ----- Radii ----- */
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* ----- Shadows: two-layer tactile ----- */
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 1px rgba(17, 24, 39, .03);
  --shadow:    0 2px 4px rgba(17, 24, 39, .04), 0 8px 20px rgba(17, 24, 39, .06);
  --shadow-md: 0 4px 6px rgba(17, 24, 39, .05), 0 12px 24px rgba(17, 24, 39, .08);
  --shadow-lg: 0 8px 16px rgba(17, 24, 39, .08), 0 20px 40px rgba(17, 24, 39, .1);
  --shadow-teal: 0 4px 10px rgba(15, 118, 110, .25), 0 10px 24px rgba(15, 118, 110, .15);

  /* ----- Typography ----- */
  --sans: "Montserrat", -apple-system, BlinkMacSystemFont, "SF Pro Display",
          "Segoe UI Variable", "Roboto Flex", "Segoe UI", sans-serif;
}

/* ============================================================
   Dark mode tokens
   ============================================================ */

/* Applied when the user has explicitly selected dark. */
[data-theme="dark"] {
  --bg: #0a0d14;
  --bg-grain: #161b2b;
  --surface: #161b2b;
  --surface-2: #1e2333;
  --ink: #f5f7fa;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --line: rgba(255, 255, 255, 0.08);
  --line-soft: rgba(255, 255, 255, 0.05);

  --teal: #14b8a6;
  --teal-deep: #5eead4;
  --teal-2: #2dd4bf;
  --teal-soft: rgba(20, 184, 166, 0.18);
  --teal-tint: rgba(20, 184, 166, 0.10);
  --teal-mist: rgba(20, 184, 166, 0.06);

  --amber: #f59e0b;
  --amber-deep: #fcd34d;
  --amber-soft: rgba(245, 158, 11, 0.18);
  --green: #10b981;
  --green-deep: #6ee7b7;
  --green-soft: rgba(16, 185, 129, 0.18);
  --red: #ef4444;
  --red-deep: #fca5a5;
  --red-soft: rgba(239, 68, 68, 0.18);

  --sidebar: #070b14;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow:    0 2px 4px rgba(0, 0, 0, .4), 0 8px 20px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, .45), 0 12px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, .5),  0 20px 40px rgba(0, 0, 0, .4);
  --shadow-teal: 0 4px 10px rgba(20, 184, 166, .35), 0 10px 24px rgba(20, 184, 166, .2);
}

/* Applied when no user preference is set ([data-theme] absent)
   and the OS prefers dark. The :not selector ensures that an
   explicit data-theme="light" wins over the OS preference. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #0a0d14;
    --bg-grain: #161b2b;
    --surface: #161b2b;
    --surface-2: #1e2333;
    --ink: #f5f7fa;
    --ink-2: #cbd5e1;
    --muted: #94a3b8;
    --line: rgba(255, 255, 255, 0.08);
    --line-soft: rgba(255, 255, 255, 0.05);

    --teal: #14b8a6;
    --teal-deep: #5eead4;
    --teal-2: #2dd4bf;
    --teal-soft: rgba(20, 184, 166, 0.18);
    --teal-tint: rgba(20, 184, 166, 0.10);
    --teal-mist: rgba(20, 184, 166, 0.06);

    --amber: #f59e0b;
    --amber-deep: #fcd34d;
    --amber-soft: rgba(245, 158, 11, 0.18);
    --green: #10b981;
    --green-deep: #6ee7b7;
    --green-soft: rgba(16, 185, 129, 0.18);
    --red: #ef4444;
    --red-deep: #fca5a5;
    --red-soft: rgba(239, 68, 68, 0.18);

    --sidebar: #070b14;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 0 0 1px rgba(255, 255, 255, .04);
    --shadow:    0 2px 4px rgba(0, 0, 0, .4), 0 8px 20px rgba(0, 0, 0, .3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, .45), 0 12px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, .5),  0 20px 40px rgba(0, 0, 0, .4);
    --shadow-teal: 0 4px 10px rgba(20, 184, 166, .35), 0 10px 24px rgba(20, 184, 166, .2);
  }
}

/* ============================================================
   Global ambient tint (very subtle, follows the body)
   ============================================================ */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle at 10% 10%, rgba(15, 118, 110, 0.025), transparent 50%),
    radial-gradient(circle at 90% 60%, rgba(217, 119, 6, 0.02),  transparent 45%);
}

[data-theme="dark"] body::before,
:root:not([data-theme="light"]) body::before {
  background-image:
    radial-gradient(circle at 10% 10%, rgba(20, 184, 166, 0.05), transparent 50%),
    radial-gradient(circle at 90% 60%, rgba(245, 158, 11, 0.03), transparent 45%);
}

/* ============================================================
   Reduced-motion accessibility (spec §11.1)
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
