/* =========================================================
   CalcHub — Premium UI stylesheet
   Glassmorphism · soft shadows · gradients · dark/light
   ========================================================= */

:root {
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --brand-3: #ec4899;
  --accent: #22c55e;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --grad-soft: linear-gradient(135deg, rgba(99,102,241,.15), rgba(236,72,153,.12));

  --bg: #f5f6fb;
  --bg-2: #eef0f8;
  --surface: #ffffff;
  --glass: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.75);
  --text: #1a1c2e;
  --muted: #5b6079;
  --line: #e6e8f2;
  --shadow: 0 10px 40px -12px rgba(31, 38, 82, 0.25);
  --shadow-sm: 0 4px 18px -6px rgba(31, 38, 82, 0.18);
  --radius: 20px;
  --radius-sm: 14px;
  --header-h: 72px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b0d1a;
  --bg-2: #0f1222;
  --surface: #161a2e;
  --glass: rgba(24, 28, 48, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text: #e9ebf5;
  --muted: #9aa1c0;
  --line: #262a44;
  --shadow: 0 20px 50px -18px rgba(0, 0, 0, 0.7);
  --shadow-sm: 0 6px 22px -8px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(236, 72, 153, 0.14), transparent 55%);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .4s ease, color .4s ease;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }

.container-xl { max-width: 1240px; }

/* Typography */
h1, h2, h3, h4 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.display-hero { font-size: clamp(2.2rem, 5vw, 4rem); font-weight: 800; }
.text-gradient {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.text-muted-2 { color: var(--muted) !important; }
.section-eyebrow {
  text-transform: uppercase; letter-spacing: .18em; font-size: .74rem;
  font-weight: 700; color: var(--brand);
}

/* ---------- Glass surfaces ---------- */
.glass {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 1030;
  height: var(--header-h);
  display: flex; align-items: center;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--glass-border);
  transition: box-shadow .3s ease;
}
.site-header.scrolled { box-shadow: var(--shadow-sm); }
.brand-logo {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 800; font-size: 1.28rem; color: var(--text);
}
.brand-logo .logo-badge {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--grad); color: #fff;
  display: grid; place-items: center; font-size: 1.15rem;
  box-shadow: 0 8px 20px -6px rgba(99, 102, 241, .6);
}
.nav-link-c {
  color: var(--muted); font-weight: 600; padding: .5rem .9rem;
  border-radius: 10px; transition: all .2s;
}
.nav-link-c:hover, .nav-link-c.active { color: var(--text); background: var(--grad-soft); }

/* Theme toggle */
.theme-toggle, .icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text); display: grid; place-items: center;
  cursor: pointer; transition: all .25s; font-size: 1.05rem;
}
.theme-toggle:hover, .icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }

/* ---------- Buttons ---------- */
.btn-gradient {
  background: var(--grad); color: #fff; border: none;
  font-weight: 700; border-radius: 12px; padding: .72rem 1.5rem;
  position: relative; overflow: hidden; isolation: isolate;
  box-shadow: 0 10px 26px -10px rgba(99, 102, 241, .7);
  transition: transform .25s ease, box-shadow .25s ease;
}
.btn-gradient:hover { transform: translateY(-2px); color: #fff; box-shadow: 0 16px 34px -10px rgba(99, 102, 241, .8); }
.btn-gradient::after {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(135deg, #ec4899, #6366f1);
  opacity: 0; transition: opacity .35s;
}
.btn-gradient:hover::after { opacity: 1; }
.btn-ghost {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  font-weight: 700; border-radius: 12px; padding: .72rem 1.4rem; transition: all .25s;
}
.btn-ghost:hover { background: var(--surface); transform: translateY(-2px); box-shadow: var(--shadow-sm); color: var(--text); }

/* ---------- Hero ---------- */
.hero { padding: clamp(3rem, 7vw, 6rem) 0 3rem; position: relative; }
.hero-badge {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--glass); border: 1px solid var(--glass-border);
  padding: .45rem 1rem; border-radius: 999px; font-weight: 600; font-size: .85rem;
  box-shadow: var(--shadow-sm);
}
.hero-stat { text-align: center; }
.hero-stat .num { font-size: 1.8rem; font-weight: 800; }
.floating-orb {
  position: absolute; border-radius: 50%; filter: blur(60px);
  opacity: .5; z-index: -1; animation: floaty 9s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-26px);} }

/* Hero search */
.hero-search {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: .5rem .5rem .5rem 1.1rem;
  box-shadow: var(--shadow); max-width: 620px;
}
.hero-search input { border: none; outline: none; background: transparent; color: var(--text); flex: 1; font-size: 1rem; }

/* ---------- Tool cards ---------- */
.tool-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tool-card {
  position: relative; padding: 1.4rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); overflow: hidden;
  transition: transform .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s, border-color .3s;
  display: flex; flex-direction: column; gap: .55rem; height: 100%;
}
.tool-card::before {
  content: ""; position: absolute; inset: 0; opacity: 0; transition: opacity .3s;
  background: var(--grad-soft);
}
.tool-card:hover { transform: translateY(-6px); box-shadow: var(--shadow); border-color: transparent; }
.tool-card:hover::before { opacity: 1; }
.tool-card > * { position: relative; z-index: 1; }
.tool-icon {
  width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center;
  font-size: 1.5rem; color: #fff; background: var(--grad);
  box-shadow: 0 10px 22px -8px rgba(99,102,241,.65);
}
.tool-card h3 { font-size: 1.06rem; margin: 0; }
.tool-card p { color: var(--muted); font-size: .86rem; margin: 0; flex: 1; }
.tool-tag {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--brand); background: var(--grad-soft); padding: .2rem .55rem; border-radius: 8px;
  align-self: flex-start;
}
.tool-arrow { color: var(--brand); font-weight: 700; display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; }

/* Category chips */
.cat-card {
  display: flex; align-items: center; gap: .9rem; padding: 1.1rem;
  border-radius: var(--radius-sm); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform .28s, box-shadow .28s; height: 100%;
}
.cat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.cat-ic { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; font-size: 1.35rem; color: #fff; flex-shrink: 0; }
.cat-card h4 { margin: 0; font-size: 1rem; color: var(--text); }
.cat-card small { color: var(--muted); }

/* Section */
.section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.8rem; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(1.5rem, 3.4vw, 2.2rem); margin: .35rem 0 0; }

/* ---------- Calculator page ---------- */
.calc-shell { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 992px) { .calc-shell { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.calc-field { margin-bottom: 1.15rem; }
.calc-field label { font-weight: 700; font-size: .9rem; margin-bottom: .4rem; display: block; }
.field-wrap { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); transition: border-color .2s, box-shadow .2s; }
.field-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(99,102,241,.15); }
.field-wrap .adorn { padding: .7rem .85rem; background: var(--bg-2); color: var(--muted); font-weight: 700; display: grid; place-items: center; white-space: nowrap; }
.field-wrap input, .field-wrap select { border: none; outline: none; background: transparent; color: var(--text); padding: .7rem .85rem; width: 100%; font-size: 1rem; font-family: inherit; }
.field-hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
input[type=range].range { width: 100%; accent-color: var(--brand); }

/* Result panel */
.result-panel { position: sticky; top: calc(var(--header-h) + 16px); }
.result-hero {
  background: var(--grad); color: #fff; border-radius: var(--radius);
  padding: 1.6rem; box-shadow: 0 20px 44px -16px rgba(99,102,241,.7); margin-bottom: 1rem;
}
.result-hero .r-label { opacity: .85; font-weight: 600; font-size: .9rem; }
.result-hero .r-value { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; }
.result-row { display: flex; justify-content: space-between; padding: .7rem 0; border-bottom: 1px dashed var(--line); }
.result-row:last-child { border-bottom: none; }
.result-row .rl { color: var(--muted); font-weight: 600; }
.result-row .rv { font-weight: 800; }
.donut { width: 170px; height: 170px; margin: 0 auto; }

.chip-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: .5rem .8rem; font-weight: 600; font-size: .85rem;
  cursor: pointer; transition: all .2s; display: inline-flex; align-items: center; gap: .4rem;
}
.chip-btn:hover { background: var(--grad-soft); border-color: transparent; transform: translateY(-2px); }

/* Info blocks */
.info-block { padding: 1.5rem; }
.info-block h2 { font-size: 1.3rem; margin-top: 0; }
.accordion-c .ac-item { border-bottom: 1px solid var(--line); }
.accordion-c .ac-q { width: 100%; text-align: left; background: none; border: none; color: var(--text); font-weight: 700; padding: 1rem 0; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 1rem; font-size: 1rem; }
.accordion-c .ac-a { max-height: 0; overflow: hidden; transition: max-height .3s ease; color: var(--muted); }
.accordion-c .ac-item.open .ac-a { max-height: 400px; padding-bottom: 1rem; }
.accordion-c .ac-item.open .ac-q i { transform: rotate(45deg); }
.accordion-c .ac-q i { transition: transform .3s; color: var(--brand); }

/* History list */
.history-item { font-size: .82rem; color: var(--muted); padding: .45rem 0; border-bottom: 1px dashed var(--line); }

/* ---------- Floating search overlay ---------- */
.search-overlay {
  position: fixed; inset: 0; z-index: 1050; display: none;
  background: rgba(10, 12, 24, .55); backdrop-filter: blur(6px);
  padding-top: 12vh;
}
.search-overlay.open { display: block; animation: fade .2s ease; }
.search-box { max-width: 620px; margin: 0 auto; }
.search-box input {
  width: 100%; padding: 1.1rem 1.3rem; font-size: 1.15rem; border-radius: 16px;
  border: 1px solid var(--glass-border); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); outline: none;
}
.search-results { margin-top: .8rem; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.search-results a { display: flex; align-items: center; gap: .8rem; padding: .85rem 1.1rem; color: var(--text); border-bottom: 1px solid var(--line); }
.search-results a:hover { background: var(--grad-soft); }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

/* ---------- Skeleton loading ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--line); border-radius: 8px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%);} }

/* ---------- Ads ---------- */
.ad-slot { margin: 1.5rem 0; text-align: center; }
.ad-slot .ad-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); display: block; margin-bottom: .4rem; }
.ad-placeholder {
  border: 1.5px dashed var(--line); border-radius: var(--radius-sm); padding: 1.4rem;
  color: var(--muted); background: var(--glass); font-weight: 600;
}
.ad-sticky-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1040; background: var(--glass); backdrop-filter: blur(14px); border-top: 1px solid var(--glass-border); padding: .5rem; text-align: center; }

/* ---------- Newsletter ---------- */
.newsletter { background: var(--grad); border-radius: 28px; padding: clamp(2rem,5vw,3.5rem); color: #fff; box-shadow: 0 24px 60px -22px rgba(99,102,241,.7); }
.newsletter input { border: none; border-radius: 12px; padding: .85rem 1.1rem; flex: 1; outline: none; }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); padding: 3.5rem 0 1.5rem; margin-top: 4rem; }
.site-footer h5 { font-size: .95rem; font-weight: 800; margin-bottom: 1rem; }
.site-footer a { color: var(--muted); display: block; padding: .28rem 0; font-weight: 500; }
.site-footer a:hover { color: var(--brand); }
.footer-bottom { border-top: 1px solid var(--line); margin-top: 2.5rem; padding-top: 1.5rem; color: var(--muted); font-size: .85rem; }

/* ---------- Blog ---------- */
.post-card { overflow: hidden; height: 100%; display: flex; flex-direction: column; }
.post-card .cover { height: 190px; background: var(--grad); background-size: cover; background-position: center; }
.post-card .body { padding: 1.3rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.post-meta { font-size: .78rem; color: var(--muted); display: flex; gap: .8rem; }
.prose { max-width: 760px; }
.prose h2, .prose h3 { margin-top: 1.8rem; }
.prose img { max-width: 100%; border-radius: 14px; }

/* ---------- Reveal animations ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .6s ease, transform .6s cubic-bezier(.2,.8,.2,1); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Breadcrumb ---------- */
.crumbs { font-size: .85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand); }

/* ---------- Utility ---------- */
.badge-soft { background: var(--grad-soft); color: var(--brand); font-weight: 700; padding: .35rem .7rem; border-radius: 8px; font-size: .78rem; }
.divider { height: 1px; background: var(--line); margin: 2rem 0; border: none; }
.page-fade { animation: pageIn .45s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none; } }

::selection { background: rgba(99,102,241,.25); }

/* Scrollbar */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 20px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

@media (max-width: 575px) {
  .result-panel { position: static; }
}
