/* ============================================================
   Karan OS — The Wilds (theme #2, Wave 32)
   A sunlit skin: an afternoon in long grass. Warm greens and a
   high blue sky, weathered paper, worn leather, brass on a
   field-kit. Every rule is scoped under body.wilds — the theme
   contract's law 1 (the base OS is whole without us) is a CSS
   rule as much as a JS one.

   Owned class names (JS builds the nodes, this file gives them
   their look):
     .wld-grass-row / .wld-blade   — the grass line above the dock
     .wld-ceremony / .wld-whisper  — the discovery moment
     .wld-panel .wld-card .wld-chip .wld-gauge — the Ledger + hub
     .wilds-app .wilds-hud .wilds-joy .wilds-look — the world app
   Every animation is wrapped in
   @media (prefers-reduced-motion: no-preference).
   ============================================================ */

/* ---- token overrides ---- */
body.wilds {
  --accent: #4f9d3a;
  --bg: #16211a;
  --text: #eef6e6;
  --text-dim: #a3b79b;
  --glass: rgba(24,38,28,.62);
  --glass-strong: rgba(26,42,31,.86);
  --border: rgba(120,190,100,.28);
  --shadow: 0 18px 50px rgba(0,0,0,.45);
  --radius: 14px;
  --font: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;

  /* wilds-only extended tokens, reused across the sections below */
  --wld-sky: #8fc9e8;
  --wld-canopy: #2f5d2a;
  --wld-leaf: #6fae4a;
  --wld-leaf-hi: #a9d97f;
  --wld-soil: #56412c;
  --wld-bark: #3c2c1d;
  --wld-sun: #ffdf9a;
  --wld-paper: #efe6cf;
  --wld-glow: 0 0 16px rgba(120,200,110,.42);
  --wld-field: linear-gradient(180deg, #244a24, #16281a 60%, #101c13);
}

/* ---- the grass line above the dock ---- */
body.wilds .wld-grass-row { }              /* layout is inline (JS owns the dock offset) */

body.wilds .wld-blade {
  display: block;
  width: 4px;
  border-radius: 3px 3px 0 0;
  transform-origin: bottom center;
  background: linear-gradient(180deg, var(--wld-leaf-hi), var(--wld-leaf) 45%, var(--wld-canopy));
  box-shadow: 0 0 6px rgba(120, 200, 110, .25);
  opacity: .85;
}

@media (prefers-reduced-motion: no-preference) {
  body.wilds .wld-blade { animation: wld-sway 3.4s ease-in-out infinite; }
  @keyframes wld-sway {
    0%, 100% { transform: rotate(-4deg) scaleY(1); }
    50%      { transform: rotate(5deg) scaleY(1.04); }
  }
}

/* ---- the discovery moment ---- */
body.wilds .wld-whisper,
.wld-ceremony .wld-whisper { will-change: opacity; }

/* ---- desktop skin ---- */
body.wilds #desktop {
  background-image:
    radial-gradient(120% 80% at 50% -20%, rgba(143, 201, 232, .30), transparent 60%),
    radial-gradient(90% 60% at 20% 110%, rgba(47, 93, 42, .38), transparent 70%);
}

body.wilds .window {
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .05);
}

body.wilds .titlebar {
  background: linear-gradient(180deg, rgba(56, 84, 50, .92), rgba(32, 52, 32, .92));
  border-bottom: 1px solid var(--border);
}

body.wilds #menubar {
  background: linear-gradient(180deg, rgba(26, 44, 30, .84), rgba(20, 34, 24, .78));
  border-bottom: 1px solid var(--border);
}

body.wilds #dock {
  background: rgba(24, 40, 28, .58);
  border: 1px solid var(--border);
}

/* ---- the shared panel look (Field Ledger, hub sections) ----
   Same skeleton as the Arcanum's collection panels: one scrim, one sheet,
   a grid of cards in three states. Transitions only — no rAF, nothing to
   tear down but the overlay itself. */
.wld-scrim {
  position: fixed; inset: 0; z-index: 1400;
  background: rgba(6, 14, 9, .62);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

.wld-panel {
  width: min(920px, 94vw);
  max-height: 84vh;
  overflow-y: auto;
  padding: 22px 24px 28px;
  border-radius: 16px;
  color: #22301f;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 40%),
    var(--wld-paper, #efe6cf);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55);
  font-family: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
}

.wld-panel h2 { margin: 0 0 2px; font-size: 26px; letter-spacing: .01em; }
.wld-panel .wld-sub { margin: 0 0 18px; color: #6b7a63; font-style: italic; font-size: 14px; }

.wld-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.wld-card {
  border-radius: 12px;
  padding: 12px 12px 14px;
  background: rgba(255, 255, 255, .45);
  border: 1px solid rgba(90, 120, 80, .28);
  text-align: center;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.wld-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, .18); }
.wld-card .wld-name { font-weight: 600; margin-top: 8px; font-size: 15px; }
.wld-card .wld-line { font-size: 12px; color: #6b7a63; margin-top: 4px; line-height: 1.35; }
.wld-card svg { display: block; margin: 0 auto; }

/* three states: kept (lit) · met (half-lit) · unseen (silhouette) */
.wld-card.met      { background: rgba(255, 255, 255, .3); }
.wld-card.met svg  { opacity: .72; filter: saturate(.5); }
.wld-card.unseen   { background: rgba(60, 70, 55, .12); border-style: dashed; }
.wld-card.unseen svg { opacity: .3; filter: grayscale(1) brightness(.4); }
.wld-card.unseen .wld-name { color: #8b9683; }

.wld-gauge { height: 5px; border-radius: 3px; background: rgba(60, 80, 50, .18); margin-top: 8px; overflow: hidden; }
.wld-gauge > i { display: block; height: 100%; background: var(--wld-leaf, #6fae4a); border-radius: 3px; }

.wld-chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  background: rgba(90, 140, 70, .18); color: #3f6b2c; margin: 0 2px;
}

.wld-x {
  position: absolute; top: 14px; right: 18px;
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid rgba(90, 120, 80, .3); background: rgba(255, 255, 255, .5);
  font-size: 17px; line-height: 1; cursor: pointer; color: #3d4a37;
}

/* ---- the world app ---- */
.wilds-app { position: relative; width: 100%; height: 100%; overflow: hidden; background: #0d1a11; }
.wilds-app .wilds-stage { position: absolute; inset: 0; }
.wilds-app .wilds-canvas { display: block; width: 100%; height: 100%; }

.wilds-app .wilds-hud { position: absolute; inset: 0; pointer-events: none; }
.wilds-app .wilds-hud > * { pointer-events: auto; }

/* stacking inside the HUD mirrors the castle's, which was tuned the hard way:
   look-drag pane 21 < chips & buttons 23 < joystick 24. The joystick is a fixed
   control and must never be covered; the look pane is invisible and loses to both. */
.wilds-app .wilds-look {
  position: absolute; right: 0; top: 0; bottom: 0; width: 50%;
  z-index: 21; touch-action: none; display: none; pointer-events: auto;
}
.wilds-app .wilds-joy {
  position: absolute; left: 18px; bottom: 18px; width: 96px; height: 96px;
  border-radius: 50%; z-index: 24; touch-action: none; display: none; pointer-events: auto;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .22);
}
.wilds-app .joy-nub {
  position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border-radius: 50%; background: rgba(255, 255, 255, .3); border: 1px solid rgba(255, 255, 255, .4);
}
body.mobile .wilds-app .wilds-joy,
body.mobile .wilds-app .wilds-look { display: block; }

.wilds-app .wilds-bar {
  position: absolute; left: 12px; top: 12px; z-index: 23;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.wilds-app .wilds-btn {
  min-height: 32px; padding: 5px 11px; border-radius: 9px; cursor: pointer;
  font: 500 13px/1.2 system-ui, sans-serif; color: #eef6e6;
  background: rgba(16, 32, 20, .6); border: 1px solid rgba(160, 220, 150, .3);
  backdrop-filter: blur(5px);
}
.wilds-app .wilds-btn:active { background: rgba(30, 60, 36, .8); }
body.mobile .wilds-app .wilds-btn { min-height: 44px; padding: 10px 14px; font-size: 14px; }

.wilds-app .wilds-note {
  position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%); z-index: 23;
  max-width: min(560px, 86%); padding: 9px 16px; border-radius: 11px; text-align: center;
  font: 15px/1.4 'Iowan Old Style', Georgia, serif; color: #f2fae9;
  background: rgba(12, 26, 16, .72); border: 1px solid rgba(160, 220, 150, .26);
  opacity: 0; transition: opacity .3s ease; pointer-events: none;
}
.wilds-app .wilds-note.on { opacity: 1; }

.wilds-app .hud-door {
  position: absolute; transform: translate(-50%, -50%); z-index: 23;
  padding: 6px 11px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  font: 500 13px/1.2 system-ui, sans-serif; color: #eef6e6;
  background: rgba(16, 32, 20, .66); border: 1px solid rgba(160, 220, 150, .34);
}
.wilds-app .hud-door.near { background: rgba(70, 130, 60, .8); border-color: rgba(200, 245, 180, .6); }
body.mobile .wilds-app .hud-door { min-height: 44px; display: flex; align-items: center; }

/* the 2.5-D fallback, for a refusal (reduced motion, no WebGL, budget denied) */
.wilds-app .wilds-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; padding: 28px; text-align: center;
  color: #eef6e6;
  background: linear-gradient(#8fc9e8 0%, #bfe0c0 44%, #5f9243 45%, #2f5d2a 100%);
}
.wilds-app .wilds-fallback h3 { margin: 0; font: 600 22px/1.3 'Iowan Old Style', Georgia, serif; color: #17300f; }
.wilds-app .wilds-fallback p { margin: 0; max-width: 44ch; color: #1e3a16; font-size: 15px; line-height: 1.5; }

/* ---- the battle HUD ---- */
.wilds-app .wld-battle {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 23;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(8, 18, 11, .82) 26%);
  color: #eef6e6;
}
.wilds-app .wld-moves { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 520px; margin: 10px auto 0; }
.wilds-app .wld-move {
  min-height: 44px; padding: 8px 12px; border-radius: 10px; cursor: pointer; text-align: left;
  font: 500 14px/1.2 system-ui, sans-serif; color: #eef6e6;
  background: rgba(20, 42, 26, .78); border: 1px solid rgba(160, 220, 150, .3);
}
.wilds-app .wld-move:disabled { opacity: .45; cursor: default; }
.wilds-app .wld-move small { display: block; margin-top: 3px; font-size: 11px; color: #a8c79c; }
.wilds-app .wld-hp { height: 8px; border-radius: 5px; background: rgba(255, 255, 255, .16); overflow: hidden; max-width: 220px; }
.wilds-app .wld-hp > i { display: block; height: 100%; background: #7ed957; transition: width .35s ease, background .35s ease; }
.wilds-app .wld-hp.low > i { background: #e8b23c; }
.wilds-app .wld-hp.crit > i { background: #e05a4a; }
.wilds-app .wld-side { display: flex; flex-direction: column; gap: 4px; font: 600 14px/1.2 system-ui, sans-serif; }
.wilds-app .wld-side small { font-weight: 400; font-size: 12px; color: #b8d3ae; }
.wilds-app .wld-log { min-height: 38px; text-align: center; font: 15px/1.3 'Iowan Old Style', Georgia, serif; }
.wilds-app .wld-rows { display: flex; justify-content: space-between; gap: 16px; max-width: 620px; margin: 0 auto; }

/* ---- 375px ---- */
@media (max-width: 420px) {
  .wld-panel { padding: 16px 14px 22px; max-height: 88vh; }
  .wld-panel h2 { font-size: 21px; }
  .wld-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .wld-card { padding: 10px 8px 12px; }
  .wld-x { width: 44px; height: 44px; top: 10px; right: 10px; }
  .wilds-app .wilds-note { bottom: 128px; font-size: 14px; }
  .wilds-app .wld-moves { grid-template-columns: 1fr; }
  .wilds-app .wld-rows { flex-direction: column; gap: 6px; }
}
