/* ============================================================================
   AIM Works design system — Apple-inspired light theme (2026-07 facelift)
   Single source of truth for chrome + primitives across all pages.
   Tokens first; primitives below. Page-specific layout stays inline per page.
   ========================================================================== */

:root {
  color-scheme: light;
  /* Surfaces */
  --bg:           #ffffff;
  --bg-alt:       #f5f5f7;   /* Apple's section gray */
  --bg-elev:      #ffffff;
  --fill-2:       #e8e8ed;   /* hover fills / subtle chips */
  --nav-bg:       rgba(255, 255, 255, 0.8);
  /* Type */
  --ink:          #1d1d1f;   /* primary text */
  --ink-2:        #6e6e73;   /* secondary text */
  --ink-3:        #86868b;   /* captions / footnotes */
  /* Lines */
  --hairline:     #d2d2d7;
  /* Accent (one blue, used sparingly) */
  --accent:       #0071e3;
  --accent-hover: #0077ed;
  --link:         #0066cc;
  /* States */
  --ok:           #1d7f37;
  --warn:         #b25000;
  --bad:          #d70015;
  /* Shape */
  --r-card:       18px;
  --r-pill:       980px;
  --shadow-soft:  0 4px 20px rgba(0, 0, 0, 0.06);
  /* Type scale */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark theme — activated by the ☀️/🌙 nav toggle (persisted in localStorage). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:           #000000;
  --bg-alt:       #161617;
  --bg-elev:      #1d1d1f;
  --fill-2:       #2c2c2e;
  --nav-bg:       rgba(22, 22, 23, 0.8);
  --ink:          #f5f5f7;
  --ink-2:        #a1a1a6;
  --ink-3:        #86868b;
  --hairline:     #3a3a3c;
  --accent:       #0071e3;
  --accent-hover: #0077ed;
  --link:         #2997ff;
  --ok:           #30d158;
  --warn:         #ff9f0a;
  --bad:          #ff453a;
  --shadow-soft:  0 4px 20px rgba(0, 0, 0, 0.55);
}

html { -webkit-text-size-adjust: 100%; }
body.aim {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────────────────────────── */
.aim h1, .aim-h1 { font-size: clamp(40px, 6vw, 56px); font-weight: 700;
                   letter-spacing: -0.015em; line-height: 1.07; margin: 0 0 12px; }
.aim h2, .aim-h2 { font-size: clamp(28px, 4vw, 40px); font-weight: 700;
                   letter-spacing: -0.01em;  line-height: 1.1;  margin: 0 0 10px; }
.aim h3, .aim-h3 { font-size: 22px; font-weight: 600; letter-spacing: -0.005em; }
.aim-lead   { font-size: 21px; color: var(--ink-2); line-height: 1.4; font-weight: 400; }
.aim-caption{ font-size: 14px; color: var(--ink-3); }
.aim a      { color: var(--link); text-decoration: none; }
.aim a:hover{ text-decoration: underline; }

/* ── Nav (frosted) ──────────────────────────────────────────────────────── */
.aim-nav {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 28px;
  height: 68px; padding: 0 max(22px, 4vw);
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.aim-nav a { color: var(--ink); font-size: 14px; opacity: 0.88; }
.aim-nav a:hover { opacity: 1; text-decoration: none; }
.aim-nav a[aria-current="page"] { opacity: 1; font-weight: 600; }
.aim-nav .brand img { height: 57px; display: block; }
.aim-nav .spacer { flex: 1; }
.aim-nav .theme-toggle {
  background: none; border: 0; cursor: pointer;
  padding: 8px 4px; font-size: 18px; line-height: 1;
}
.aim-nav .theme-toggle::after { content: "☀️"; }
:root[data-theme="dark"] .aim-nav .theme-toggle::after { content: "🌙"; }
/* Logo art is dark navy — flip it light on dark chrome (PNG is transparent). */
:root[data-theme="dark"] .aim-nav .brand img { filter: invert(1) hue-rotate(180deg); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.aim-btn {
  display: inline-block; border: 0; cursor: pointer;
  background: var(--accent); color: #fff;
  font-family: var(--font); font-size: 17px; font-weight: 400;
  padding: 11px 22px; border-radius: var(--r-pill);
  transition: background 0.15s ease;
}
.aim-btn:hover { background: var(--accent-hover); text-decoration: none; }
.aim a.aim-btn { color: #fff; }
.aim a.aim-btn-secondary { color: var(--accent); }
.aim-btn-secondary {
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent);
}
.aim-btn-secondary:hover { background: rgba(0, 113, 227, 0.06); }
.aim-btn-sm { font-size: 14px; padding: 8px 16px; }

/* ── Sections & cards ───────────────────────────────────────────────────── */
.aim-section     { padding: 88px max(22px, 4vw); }
.aim-section-alt { background: var(--bg-alt); }
.aim-wrap        { max-width: 1024px; margin: 0 auto; }
.aim-card {
  background: var(--bg-elev); border-radius: var(--r-card);
  padding: 28px; box-shadow: var(--shadow-soft);
}
.aim-section-alt .aim-card { box-shadow: none; }
.aim-tile { background: var(--bg-alt); border-radius: var(--r-card); padding: 28px; }
.aim-hairline { border: 0; border-top: 1px solid var(--hairline); margin: 0; }

/* ── Forms (calculators) ────────────────────────────────────────────────── */
.aim input[type="number"], .aim input[type="text"], .aim input[type="email"],
.aim select, .aim textarea {
  font-family: var(--font); font-size: 17px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--hairline);
  border-radius: 12px; padding: 10px 14px; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box; width: 100%;
}
.aim input:focus, .aim select:focus, .aim textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
}
.aim label { font-size: 14px; color: var(--ink-2); font-weight: 500; }

/* ── Results / tables ───────────────────────────────────────────────────── */
.aim-result {
  background: var(--bg-alt); border-radius: var(--r-card);
  padding: 24px 28px;
}
.aim-result .num { font-size: 40px; font-weight: 700; letter-spacing: -0.01em; }
.aim-result .unit{ font-size: 17px; color: var(--ink-2); }
.aim table { border-collapse: collapse; width: 100%; font-size: 15px; }
.aim th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3);
          text-transform: uppercase; letter-spacing: 0.06em;
          padding: 8px 12px; border-bottom: 1px solid var(--hairline); }
.aim td { padding: 10px 12px; border-bottom: 1px solid var(--hairline); }
.aim tr:last-child td { border-bottom: 0; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.aim-footer {
  background: var(--bg-alt); border-top: 1px solid var(--hairline);
  padding: 34px max(22px, 4vw); font-size: 12px; color: var(--ink-3);
}
.aim-footer a { color: var(--ink-2); }
.aim-footer-cols {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 36px;
  max-width: 1024px; margin: 0 auto;
}
.aim-footer-cols h4 {
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 10px;
}
.aim-footer-cols ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 7px;
}
.aim-footer-bottom {
  max-width: 1024px; margin: 22px auto 0; padding-top: 18px;
  border-top: 1px solid var(--hairline);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
}

/* ── Back to top ────────────────────────────────────────────────────────── */
.aim-top-btn {
  position: fixed; right: 22px; bottom: 22px; z-index: 90;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-elev); color: var(--ink);
  border: 1px solid var(--hairline); box-shadow: var(--shadow-soft);
  font-family: var(--font); font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease,
              background 0.15s ease;
}
.aim-top-btn.show { opacity: 1; visibility: visible; transform: none; }
.aim-top-btn:hover { background: var(--fill-2); }
@media (prefers-reduced-motion: reduce) {
  .aim-top-btn { transition: none; }
  html { scroll-behavior: auto !important; }
}

/* ── Badges / pills ─────────────────────────────────────────────────────── */
.aim-pill { display: inline-block; font-size: 12px; font-weight: 600;
            padding: 4px 12px; border-radius: var(--r-pill);
            background: var(--bg-alt); color: var(--ink-2); }
.aim-pill-blue { background: rgba(0, 113, 227, 0.1); color: var(--accent); }
.aim-pill-ok   { background: rgba(29, 127, 55, 0.1);  color: var(--ok); }

@media (max-width: 640px) {
  .aim-section { padding: 56px 20px; }
  .aim-nav { gap: 16px; overflow-x: auto; }
  /* ≥44px tap targets inside the 48px nav bar */
  .aim-nav a { padding: 14px 2px; white-space: nowrap; }
  .aim-nav a.aim-btn { padding: 8px 16px; }
  .aim-footer-cols { grid-template-columns: 1fr 1fr; gap: 24px; }
}
