/* MoneyCalc Hub — light theme, performance-first (no external fonts/frameworks) */
:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --text: #1c2733;
  --muted: #5b6b7b;
  --primary: #0f6b4f;
  --primary-dark: #0b523c;
  --accent: #0e4c8a;
  --border: #e3e9f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 40, 60, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 17px;
  -webkit-tap-highlight-color: rgba(15, 107, 79, .12);
  overflow-x: hidden;
}

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

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { font-size: 1.3rem; font-weight: 800; color: var(--text); text-decoration: none; }
.logo span { color: var(--primary); }
.main-nav a { color: var(--muted); text-decoration: none; margin-left: 24px; font-weight: 600; font-size: .95rem; }

/* Hero */
.hero { text-align: center; padding: 56px 10px 32px; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.2; margin-bottom: 14px; }
.hero p { color: var(--muted); max-width: 640px; margin: 0 auto 22px; }

.btn { display: inline-block; padding: 12px 26px; border-radius: 8px; text-decoration: none; font-weight: 700; }
.btn-primary { background: var(--primary); color: #fff; }

h2 { font-size: 1.5rem; margin: 34px 0 16px; }

/* Cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; text-decoration: none; color: var(--text); box-shadow: var(--shadow);
  transition: transform .15s ease;
  display: flex; flex-direction: column; gap: 8px;
}
.card h3 { font-size: 1.12rem; }
.card p { color: var(--muted); font-size: .95rem; flex: 1; }
.card-link { color: var(--primary); font-weight: 700; font-size: .92rem; }

.trust-strip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin: 34px 0 48px; }
.trust-strip ul { list-style: none; display: grid; gap: 10px; }

/* Calculators */
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; margin: 24px 0 48px; }

.calc-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.calc-box h1 { font-size: 1.6rem; margin-bottom: 6px; }
.calc-box .subtitle { color: var(--muted); margin-bottom: 20px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 1rem; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 3px; }

.btn-calc { width: 100%; padding: 13px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 1.05rem; font-weight: 700; cursor: pointer; }

.result-box { margin-top: 22px; background: #eef7f2; border: 1px solid #cfe7db; border-radius: 10px; padding: 18px; }
.result-main { font-size: 2rem; font-weight: 800; color: var(--primary-dark); }
.result-rows { margin-top: 12px; display: grid; gap: 6px; font-size: .95rem; }
.result-rows div { display: flex; justify-content: space-between; }
.result-rows span:last-child { font-weight: 700; }
.formula-note { margin-top: 14px; font-size: .85rem; color: var(--muted); font-style: italic; }

/* Article */
.article { max-width: 760px; }
.article h1 { font-size: clamp(1.6rem, 3.5vw, 2.2rem); line-height: 1.25; margin: 30px 0 10px; }
.article .meta { color: var(--muted); font-size: .9rem; margin-bottom: 26px; }
.article h2 { margin-top: 32px; }
.article p { margin-bottom: 18px; }
.article ul, .article ol { margin: 0 0 18px 24px; }
.article blockquote { border-left: 4px solid var(--primary); background: var(--surface); padding: 14px 18px; margin: 20px 0; border-radius: 0 8px 8px 0; color: var(--muted); }

/* Sidebar */
.sidebar { position: sticky; top: 76px; display: grid; gap: 18px; }
.sidebar .side-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.sidebar h3 { font-size: 1rem; margin-bottom: 10px; }
.sidebar ul { list-style: none; display: grid; gap: 8px; }
.sidebar a { color: var(--accent); text-decoration: none; font-size: .93rem; }

/* Ad slots — reserved space to avoid layout shift (CLS-friendly) */
.ad-slot {
  margin: 26px 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: repeating-linear-gradient(45deg, #f2f5f9, #f2f5f9 12px, #eef1f6 12px, #eef1f6 24px);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: .8rem; letter-spacing: .05em; text-transform: uppercase;
}
.ad-leaderboard { min-height: 110px; }
.ad-in-content { min-height: 260px; }
.ad-sidebar { min-height: 600px; margin: 0; }

/* Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); margin-top: 40px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; padding: 22px 20px; font-size: .9rem; color: var(--muted); }
.footer-inner nav a { color: var(--muted); text-decoration: none; margin-left: 18px; }

/* Legal pages */
.legal { max-width: 760px; padding-bottom: 40px; }
.legal h1 { margin: 30px 0 18px; }
.legal h2 { margin-top: 26px; }
.legal p, .legal li { color: #3d4c5c; margin-bottom: 12px; }

/* ============================================================
   Responsive: PC (default) / tablet / H5 mobile
   ============================================================ */

/* ---------- Small tablet & up: hover effects only for real pointers ----------
   Tablets report touch as primary input; hover lift feels "stuck" there. */
@media (hover: hover) and (pointer: fine) {
  .card:hover { transform: translateY(-3px); }
  .main-nav a:hover { color: var(--primary); }
  .btn-primary:hover { background: var(--primary-dark); }
  .btn-calc:hover { background: var(--primary-dark); }
  .footer-inner nav a:hover { color: var(--primary); }
  .sidebar a:hover { text-decoration: underline; }
}

/* ---------- Large tablets / iPad Pro (1025–1366px) ----------
   These exceed the 1024px cutoff and would otherwise get the full PC layout.
   Cap the container and slim the sidebar so content stays the focus. */
@media (min-width: 1025px) and (max-width: 1366px) {
  .container { max-width: 1080px; }
  .calc-layout { grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; }
  .article { max-width: 100%; }
  .hero { padding: 44px 10px 26px; }
  /* On iPad the sticky ad tower is capped so it never dominates the viewport */
  .ad-sidebar { min-height: 550px; max-height: calc(100vh - 140px); }
}

/* ---------- Tablet landscape (901–1024px): keep two columns, slimmer sidebar ---------- */
@media (min-width: 901px) and (max-width: 1024px) {
  .calc-layout { grid-template-columns: minmax(0, 1fr) 260px; gap: 22px; }
  .sidebar { top: 70px; }
  .ad-sidebar { min-height: 500px; }
  .hero { padding: 46px 10px 28px; }
  .article { max-width: 100%; }

  /* Touch targets for tablets held in hand */
  .btn { min-height: 48px; }
  .field input, .field select { min-height: 48px; font-size: 16px; }
  .btn-calc { min-height: 50px; }
}

/* ---------- Tablet portrait & narrow (≤900px): sidebar drops below content ---------- */
@media (max-width: 900px) {
  .calc-layout { grid-template-columns: 1fr; gap: 18px; }

  .sidebar { position: static; grid-template-columns: 1fr 1fr; gap: 14px; }
  /* Sidebar ad becomes a compact in-flow unit, spanning both columns */
  .sidebar .ad-sidebar { grid-column: 1 / -1; min-height: 280px; }

  .article { max-width: 100%; }

  .hero { padding: 40px 8px 24px; }
  h2 { margin-top: 26px; }

  /* Tablet touch targets: same 48px comfort standard as phones */
  .btn { min-height: 48px; }
  .field input, .field select { padding: 11px; min-height: 48px; font-size: 16px; }
  .btn-calc { padding: 14px; min-height: 50px; }
  .main-nav a { padding: 10px 0; } /* larger tap area around nav links */

  /* iPad home indicator / rounded corners: keep footer links off the gesture bar */
  .site-footer { padding-bottom: env(safe-area-inset-bottom, 0); }
}

/* ---------- H5 mobile (< 640px) ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .container { padding: 0 16px; }

  /* Header: tighter nav, no overflow */
  .header-inner { height: 54px; }
  .logo { font-size: 1.15rem; }
  .main-nav a { margin-left: 14px; font-size: .88rem; }
  .main-nav { display: flex; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Hero */
  .hero { padding: 30px 4px 20px; }
  .hero h1 { font-size: 1.55rem; }
  .hero p { font-size: .95rem; }

  /* Touch targets: buttons and inputs comfortably tappable */
  .btn { padding: 14px 24px; min-height: 48px; }
  .btn-primary { width: 100%; text-align: center; }

  .field input, .field select { padding: 12px; min-height: 48px; font-size: 16px; } /* 16px prevents iOS focus zoom */
  .btn-calc { padding: 15px; min-height: 52px; font-size: 1.05rem; }

  /* Calculator box */
  .calc-box { padding: 18px 16px; }
  .calc-box h1 { font-size: 1.35rem; }
  .result-main { font-size: 1.6rem; }
  .result-box { padding: 14px; }

  /* Cards */
  .card-grid { grid-template-columns: 1fr; gap: 14px; }
  .card { padding: 18px; }

  /* Trust strip */
  .trust-strip { padding: 18px; }

  /* Article */
  .article h1 { font-size: 1.45rem; margin-top: 22px; }
  .article h2 { font-size: 1.2rem; }

  /* Ad slots: shorter leaderboard on small screens, less dead space */
  .ad-leaderboard { min-height: 100px; }
  .ad-in-content { min-height: 250px; }
  .ad-sidebar { min-height: 250px; margin-top: 0; }

  /* Sidebar: boxes stack, ad last */
  .sidebar { grid-template-columns: 1fr; }

  /* Footer */
  .footer-inner { flex-direction: column; text-align: center; padding: 18px 16px; }
  .footer-inner nav a { margin: 0 10px; }
}

/* ---------- Very small phones (< 380px) ---------- */
@media (max-width: 380px) {
  .logo { font-size: 1.02rem; }
  .main-nav a { margin-left: 10px; font-size: .82rem; }
  .hero h1 { font-size: 1.35rem; }
  .result-main { font-size: 1.45rem; }
}

/* ---------- Short landscape phones: reclaim vertical space ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  .site-header { position: static; }
  .hero { padding: 18px 8px 10px; }
  .hero p { display: none; }
}

/* ---------- Print (PC) ---------- */
@media print {
  .site-header, .site-footer, .ad-slot, .sidebar { display: none !important; }
  body { background: #fff; color: #000; }
}
