/* ═══════════════════════════════════════════════════════════════
   FRS Web App — Shared Design System
   Forrestania Resources (ASX: FRS)
   ═══════════════════════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Source+Sans+3:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

/* ── Design Tokens ── */
:root {
  /* Brand */
  --color-gold: #C4922A;
  --color-gold-light: #E8C868;
  --color-gold-subtle: rgba(196, 146, 42, 0.08);
  --color-gold-border: #B8860B;
  --color-gold-text: #9A6700;

  /* Phase Colors */
  --color-phase-1: #7E5FC2;  /* Exploration — purple */
  --color-phase-2: #1B7A3D;  /* Acquisition — green */
  --color-phase-3: #D97B2B;  /* Development — amber */
  --color-phase-4: #2266CC;  /* Current/Blueprint — blue */
  --color-phase-5: #C4922A;  /* Future — gold */

  /* Semantic */
  --color-success: #1B7A3D;
  --color-success-light: #3FB950;
  --color-success-subtle: rgba(27, 122, 61, 0.08);
  --color-error: #CF222E;
  --color-error-light: #F85149;
  --color-error-subtle: rgba(207, 34, 46, 0.08);
  --color-info: #2266CC;
  --color-info-light: #58A6FF;
  --color-info-subtle: rgba(34, 102, 204, 0.08);
  --color-warning: #D97B2B;

  /* Dark Surfaces */
  --color-dark-bg: #0B0F14;
  --color-dark-surface: #141A22;
  --color-dark-elevated: #1C2430;
  --color-dark-border: #2A3240;
  --color-dark-text: #E6EDF3;
  --color-dark-text-secondary: #8B949E;
  --color-dark-text-muted: #484F58;

  /* Light Surfaces */
  --color-bg: #F4F1EC;
  --color-surface: #FEFDFB;
  --color-surface-secondary: #F0EDE7;
  --color-border: #D4CCBF;
  --color-border-subtle: #E8E3DA;
  --color-text: #1A1E24;
  --color-text-secondary: #57606A;
  --color-text-muted: #8C929E;

  /* Warm UI Grays (replacing GitHub-derived cool grays) */
  --color-ui-border: #CCC5B8;        /* was #d0d7de */
  --color-ui-text: #2C2A26;          /* was #1f2328 */
  --color-ui-text-soft: #6B6560;     /* was #57606a */
  --color-ui-text-faint: #9B948C;    /* was #8c959f */
  --color-ui-blue: #2266CC;          /* was #58a6ff / #1f6feb — use brand blue */
  --color-ui-blue-light: #4D8FE0;    /* hover / lighter blue */

  /* Map */
  --color-map-bg: #F0EDE7;

  /* Spacing (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Typography */
  --font-display: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-body: 'Source Sans 3', system-ui, -apple-system, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 24px 80px rgba(0, 0, 0, 0.2);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

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

/* ── Base Typography ── */
body {
  font-family: var(--font-body);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, .big-stat, .prod-value, .col-title, .lp-title, .lp-mst-text, .summary-header {
  font-family: var(--font-display);
}

/* Tabular numerals for data */
.big-stat, .prod-value, .cash-value, .stat-value, .rp-oz, .np-oz, .bar-label, .rp-stat .val, .np-stat .val, .tl-stat .val {
  font-variant-numeric: tabular-nums;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ── Focus States (Accessibility) ── */
:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}
input:focus-visible {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 3px var(--color-gold-subtle);
}

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

/* ── Common Component: Phase Badges ── */
.phase-badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 10px;
  margin-right: 6px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}
.phase-1 { background: var(--color-phase-1); color: #fff; }
.phase-2 { background: var(--color-phase-2); color: #fff; }
.phase-3 { background: var(--color-phase-3); color: var(--color-dark-bg); }
.phase-4 { background: var(--color-phase-4); color: #fff; }
.phase-5 { background: var(--color-phase-5); color: var(--color-dark-bg); }

/* ── Common Component: Tags ── */
.tag {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--color-surface-secondary);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

/* ── Common Component: Status Badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  margin-top: 6px;
}
.status-badge.exploration { background: rgba(126, 95, 194, 0.12); color: var(--color-phase-1); }
.status-badge.commissioning { background: rgba(34, 102, 204, 0.1); color: var(--color-phase-4); }
.status-badge.production { background: rgba(196, 146, 42, 0.12); color: var(--color-gold-text); }

/* ── Common Component: Metric Section ── */
.metric-section {
  border-bottom: 1px solid var(--color-border-subtle);
  padding-bottom: 14px;
}
.metric-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.metric-section .section-title {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-section .section-title .icon {
  font-size: 13px;
}

/* ── Common Component: Big Stat ── */
.big-stat {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
}
.big-stat .unit {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-left: 2px;
}

/* ── Common Component: Stat Detail ── */
.stat-detail {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
  line-height: 1.5;
}

/* ── Common Component: Tag List ── */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: 6px;
}

/* ── Common Component: Resource Bar ── */
.resource-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: 6px;
}
.resource-bar .bar-track, .bar-track {
  flex: 1;
  height: 8px;
  background: var(--color-surface-secondary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.resource-bar .bar-fill, .bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 0.5s ease;
}
.resource-bar .bar-label, .bar-label {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  min-width: 65px;
  text-align: right;
}

/* ── Common Component: Resource List ── */
.resource-list {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.resource-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
  gap: var(--space-2);
}
.resource-item .res-name { color: var(--color-text); font-weight: 500; flex: 1; min-width: 0; }
.resource-item .res-oz { color: var(--color-text-secondary); font-weight: 600; white-space: nowrap; text-align: right; min-width: 140px; }

/* ── Common Component: Plant Card ── */
.plant-card {
  background: var(--color-surface-secondary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-top: 6px;
}
.plant-card .plant-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}
.plant-card .plant-detail {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* ── Common Component: Nav Buttons ── */
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 28px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}
.nav-btn.primary {
  background: var(--color-phase-4);
  color: #fff;
}
.nav-btn.primary:hover {
  background: #1a57a8;
}
.nav-btn.secondary {
  background: var(--color-surface-secondary);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.nav-btn.secondary:hover {
  background: var(--color-border-subtle);
}
.nav-btn .btn-icon {
  font-size: 16px;
}

/* ── Keyframe: Ore Flow ── */
@keyframes ore-flow {
  from { stroke-dashoffset: 40; }
  to { stroke-dashoffset: 0; }
}
@keyframes ore-glow-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}
@keyframes target-pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(1.3); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ══════════════════════════════════════════════════════════════════
   Entrance Animations — Story Mode & Panels
   ══════════════════════════════════════════════════════════════════ */

/* Fade-slide-up for cards and panels */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Fade-scale for map markers appearing */
@keyframes fadeScale {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* Slide in from right for side panels */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Timeline bar slide-up reveal */
@keyframes slideUpReveal {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Gold shimmer for highlight moments */
@keyframes goldShimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* Utility classes — add to elements for animation */
.anim-fade-up {
  animation: fadeSlideUp 0.4s ease-out both;
}
.anim-fade-scale {
  animation: fadeScale 0.35s ease-out both;
}
.anim-slide-right {
  animation: slideInRight 0.4s ease-out both;
}
.anim-slide-up-reveal {
  animation: slideUpReveal 0.35s ease-out both;
}

/* Staggered delays for child elements */
.anim-stagger > *:nth-child(1) { animation-delay: 0ms; }
.anim-stagger > *:nth-child(2) { animation-delay: 60ms; }
.anim-stagger > *:nth-child(3) { animation-delay: 120ms; }
.anim-stagger > *:nth-child(4) { animation-delay: 180ms; }
.anim-stagger > *:nth-child(5) { animation-delay: 240ms; }
.anim-stagger > *:nth-child(6) { animation-delay: 300ms; }
.anim-stagger > *:nth-child(7) { animation-delay: 360ms; }
.anim-stagger > *:nth-child(8) { animation-delay: 420ms; }

/* Gold shimmer accent — apply to headings for emphasis */
.gold-shimmer {
  background: linear-gradient(
    90deg,
    var(--color-gold) 0%,
    var(--color-gold-light) 40%,
    #fff 50%,
    var(--color-gold-light) 60%,
    var(--color-gold) 100%
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: goldShimmer 3s ease-in-out infinite;
}

/* ══════════════════════════════════════════════════════════════════
   Geological Texture & Depth Effects
   ══════════════════════════════════════════════════════════════════ */

/* Subtle topographic noise overlay — apply to page backgrounds */
.geo-texture::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* Topographic contour lines — lighter, more geological feel */
.geo-contours::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='c' width='200' height='200' patternUnits='userSpaceOnUse'%3E%3Ccircle cx='100' cy='100' r='30' fill='none' stroke='%23927648' stroke-width='0.5'/%3E%3Ccircle cx='100' cy='100' r='55' fill='none' stroke='%23927648' stroke-width='0.5'/%3E%3Ccircle cx='100' cy='100' r='80' fill='none' stroke='%23927648' stroke-width='0.5'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='200' height='200' fill='url(%23c)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

/* Premium dark header gradient with subtle noise depth */
.dark-header-depth {
  position: relative;
}
.dark-header-depth::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='256' height='256' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* Gold vein accent border — use on premium cards */
.gold-vein-border {
  border-image: linear-gradient(
    180deg,
    var(--color-gold) 0%,
    var(--color-gold-light) 30%,
    transparent 70%
  ) 1;
}

/* Elevated card with warm shadow */
.card-elevated {
  box-shadow:
    0 1px 2px rgba(146, 118, 72, 0.06),
    0 4px 16px rgba(146, 118, 72, 0.08),
    0 12px 40px rgba(146, 118, 72, 0.04);
}
