/* ==========================================================================
   Wildsforge shared site styles (homepage, guides and future content pages).

   The farming calculator still carries its own inline copy of the tokens;
   keep the two in sync until it is moved over to this file.

   Sections: 1 tokens · 2 base · 3 header/brand · 4 layout and breadcrumb ·
   5 buttons and cards · 6 photos · 7 footer · 8 motion · 9 mobile
   ========================================================================== */

/* ==========================================================================
   1. Design tokens (light default; dark via OS preference or data-theme)
   ========================================================================== */
:root {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);

  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-2: #efe9dc;
  --text: #2a2a22;
  --muted: #5f5c4f;
  --border: #ddd6c4;
  --accent: #3f7a3a;
  --accent-text: #ffffff;
  --focus: #1b5fbf;
  --warn: #8a5c0a;
  --spark: #e0a82e;
  --logo-bg: #e6efd9;
  --logo-metal: #3a3a32;
  --hill-far: #dfe6cf;
  --hill-near: #cbd9b8;
  --radius: 10px;
  --wrap: 1100px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171a15; --surface: #20241d; --surface-2: #272c23; --text: #e8e6da; --muted: #a8a692;
    --border: #35392f; --accent: #7fc274; --accent-text: #10200e; --focus: #8fc4ff; --warn: #e0b25a;
    --spark: #f3d27a; --logo-bg: #26301f; --logo-metal: #cfd4c4; --hill-far: #1f251b; --hill-near: #263022;
  }
}

:root[data-theme="dark"] {
  --bg: #171a15; --surface: #20241d; --surface-2: #272c23; --text: #e8e6da; --muted: #a8a692;
  --border: #35392f; --accent: #7fc274; --accent-text: #10200e; --focus: #8fc4ff; --warn: #e0b25a;
  --spark: #f3d27a; --logo-bg: #26301f; --logo-metal: #cfd4c4; --hill-far: #1f251b; --hill-near: #263022;
}

/* ==========================================================================
   2. Base and accessibility helpers
   ========================================================================== */
*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }

a { color: var(--accent); }

img { max-width: 100%; height: auto; }

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

.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}
.skip-link:focus { top: 8px; }

/* ==========================================================================
   3. Header and brand (logo with drifting sparkles)
   ========================================================================== */
.page-header { max-width: var(--wrap); margin: 0 auto; padding: 18px 16px 4px; }

.brand { position: relative; display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand__logo { flex: none; width: 48px; height: 48px; }
.brand__name { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: 0.02em; }
.brand__tag { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.logo__badge { fill: var(--logo-bg); stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.logo__anvil { fill: var(--logo-metal); }
.logo__leaf { fill: var(--accent); }
.logo__vein { fill: none; stroke: var(--logo-bg); stroke-width: 1.4; stroke-linecap: round; }

/* Drifting motes, like the shimmer on a ready-to-harvest crop (created by site.js) */
.sparkles { position: absolute; inset: -8px 0 0 0; pointer-events: none; }
.sparkle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--spark);
  box-shadow: 0 0 6px 1px var(--spark);
  opacity: 0;
  animation: sparkle 3.4s ease-out var(--delay) infinite;
}

/* ==========================================================================
   4. Layout and breadcrumb
   ========================================================================== */
.page-main { max-width: var(--wrap); margin: 0 auto; padding: 12px 16px 16px; }

.breadcrumb { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px; color: var(--muted); font-size: 13px; }
.breadcrumb li + li::before { content: "›"; margin-right: 4px; }
.breadcrumb a { color: inherit; }

.section { margin-top: 44px; }
.section__title { font-size: 21px; }
.section__intro { max-width: 720px; margin: 6px 0 16px; color: var(--muted); }

/* ==========================================================================
   5. Buttons and cards
   ========================================================================== */
.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.12s, filter 0.12s;
}
.button:hover { filter: brightness(1.08); }
.button:active { transform: scale(0.97); }
.button--ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  animation: rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
a.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.08);
}

/* A card with a photo strip across the top */
.card__media { margin: -16px -16px 6px; aspect-ratio: 16 / 7; overflow: hidden; }
.card__media img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
a.card:hover .card__media img { transform: scale(1.04); }

.card__icon { width: 36px; height: 36px; color: var(--accent); }
.card__title { font-size: 17px; }
.card__text { margin: 0; color: var(--muted); }
.card__cta { margin-top: auto; padding-top: 6px; color: var(--accent); font-weight: 600; }
.card__badge {
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--logo-bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

/* Placeholder cards for tools and guides that are still being written */
.card--soon { border-style: dashed; background: transparent; animation-delay: 0.07s; }

/* ==========================================================================
   6. Photos: soften screenshots so they sit inside the site's warm theme
   ========================================================================== */
.photo {
  position: relative;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.12);
}
.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.9) contrast(1.03);
}
/* Warm wash plus a soft vignette that fades the edges into the page */
.photo::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgb(20 24 15 / 0.35) 100%),
    linear-gradient(180deg, rgb(255 214 120 / 0.10), rgb(63 122 58 / 0.10));
}
.photo figcaption,
.photo__caption { margin-top: 6px; color: var(--muted); font-size: 13px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .photo img { filter: saturate(0.85) brightness(0.88) contrast(1.05); }
}
:root[data-theme="dark"] .photo img { filter: saturate(0.85) brightness(0.88) contrast(1.05); }

/* ==========================================================================
   7. Footer (with a rolling-hills illustration on top)
   ========================================================================== */
.page-footer { margin-top: 56px; color: var(--muted); font-size: 13px; }
.page-footer__hills { display: block; width: 100%; height: 70px; }
.hills__far { fill: var(--hill-far); }
.hills__near { fill: var(--hill-near); }
.hills__dragon { fill: var(--muted); opacity: 0.55; }
.page-footer__inner {
  padding: 18px 16px 90px; /* bottom room for the support tag */
  background: var(--hill-near);
}
.page-footer__content { max-width: var(--wrap); margin: 0 auto; }
.page-footer p { margin: 4px 0; }
.page-footer a { color: inherit; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 10px; padding: 0; list-style: none; font-weight: 600; }

/* ==========================================================================
   8. Motion
   ========================================================================== */
@keyframes sparkle {
  0%   { opacity: 0; transform: translate(0, 6px) scale(0.5); }
  25%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--drift), -26px) scale(1); }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

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

/* ==========================================================================
   9. Mobile
   ========================================================================== */
@media (max-width: 820px) {
  .brand__name { font-size: 23px; }
  .section { margin-top: 34px; }
  .page-footer__hills { height: 44px; }
}
