/*
Theme Name: WidgetPress
Theme URI: https://widget.us.com/
Author: Widget.us.com
Author URI: https://widget.us.com/
Description: Lightweight utility theme powering the Widget.us.com calculator and widget library.
Version: 1.6.2
Requires at least: 6.5
Tested up to: 7.0.3
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: widgetpress
Tags: one-column, custom-menu, featured-images, translation-ready, block-styles, wide-blocks, accessibility-ready
*/

/* widget.us.com — Design System v2 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  /* Brand */
  --blue-dark: #0f2846;
  --blue-mid: #2563eb;
  --blue-light: #3b82f6;
  --blue-pale: #eff6ff;
  --blue-border: #bfdbfe;
  --blue-tint: #e0edff;

  /* Accents */
  --green-confirm: #16a34a;
  --green-pale: #f0fdf4;
  --green-tint: #dcfce7;
  --orange-accent: #ea580c;
  --orange-pale: #fff7ed;
  --orange-tint: #fed7aa;
  --purple-tint: #ede9fe;
  --purple-mid: #7c3aed;
  --pink-tint: #fce7f3;
  --pink-mid: #db2777;
  --teal-tint: #ccfbf1;
  --teal-mid: #0d9488;

  /* Neutrals */
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-light: #64748b;
  --text-muted: #94a3b8;
  --bg-white: #ffffff;
  --bg-off: #f8fafc;
  --bg-tint: #f1f5f9;
  --border-light: #e2e8f0;
  --border-mid: #cbd5e1;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px -6px rgba(15, 23, 42, 0.10), 0 4px 10px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 24px 40px -12px rgba(15, 23, 42, 0.14), 0 8px 20px -8px rgba(15, 23, 42, 0.06);
  --shadow-ring: 0 0 0 3px rgba(37, 99, 235, 0.14);

  /* Shape */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* Layout */
  --max-width: 1180px;
  --max-width-narrow: 760px;

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur: 220ms;
  --dur-slow: 320ms;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  color: var(--text-primary);
  line-height: 1.6;
  background: var(--bg-off);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { letter-spacing: -0.02em; line-height: 1.2; }
h1 { letter-spacing: -0.028em; }

a { color: var(--blue-mid); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: var(--blue-dark); }

:focus-visible {
  outline: 2px solid var(--blue-mid);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --- Skip link --- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 10px 16px;
  background: var(--blue-mid);
  color: #fff;
  font-weight: 600;
  border-radius: 0 0 var(--radius-sm) 0;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
  outline: 2px solid #fff;
  outline-offset: -4px;
}

button, input, select, textarea { font-family: inherit; }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* --- Header --- */
.site-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--blue-dark);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.site-logo::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--blue-mid) 0%, #6366f1 100%);
  box-shadow: 0 4px 10px -2px rgba(37, 99, 235, 0.4);
}

.site-logo span { color: var(--blue-light); font-weight: 700; }

.nav-links { display: flex; gap: 4px; list-style: none; align-items: center; }
.nav-links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-links a:hover { color: var(--blue-mid); background: var(--blue-pale); }
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-secondary);
}

/* --- Hero --- */
.hero-compact {
  position: relative;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.35) 0%, transparent 60%),
    linear-gradient(180deg, var(--blue-dark) 0%, #0a1e39 100%);
  color: #fff;
  padding: 72px 24px 96px;
  text-align: center;
  overflow: hidden;
}

.hero-compact::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(59, 130, 246, 0.15) 0%, transparent 40%);
  pointer-events: none;
}

.hero-compact > * { position: relative; z-index: 1; }

.hero-compact h1 {
  font-size: clamp(2rem, 4vw + 1rem, 3.2rem);
  font-weight: 800;
  margin-bottom: 14px;
  letter-spacing: -0.035em;
}

.hero-compact p {
  font-size: clamp(1rem, 0.5vw + 0.9rem, 1.15rem);
  opacity: 0.82;
  max-width: 620px;
  margin: 0 auto;
  line-height: 1.5;
}

.hero-compact .eyebrow {
  display: inline-block;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 20px;
}

/* --- Calculator Container --- */
.calc-wrapper {
  max-width: 960px;
  margin: -48px auto 64px;
  position: relative;
  z-index: 10;
  padding: 0 24px;
}

.calc-card {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.calc-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.calc-inputs {
  padding: 40px 36px;
  border-right: 1px solid var(--border-light);
}

.calc-results {
  padding: 40px 36px;
  background: linear-gradient(180deg, var(--bg-off) 0%, #eef2f7 100%);
}

.calc-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--blue-mid);
  margin-bottom: 24px;
}

/* --- Form Controls --- */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input[type="number"],
.form-group input[type="text"],
.form-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 0.98rem;
  color: var(--text-primary);
  background: var(--bg-white);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  font-variant-numeric: tabular-nums;
}

.form-group input:hover,
.form-group select:hover { border-color: var(--border-mid); }

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--blue-mid);
  box-shadow: var(--shadow-ring);
}

.input-hint {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 5px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.btn-calculate {
  display: block;
  width: 100%;
  padding: 13px;
  background: linear-gradient(180deg, var(--blue-mid) 0%, #1d4ed8 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease), filter var(--dur) var(--ease);
  margin-top: 10px;
  box-shadow: 0 4px 12px -2px rgba(37, 99, 235, 0.4);
  letter-spacing: -0.005em;
}

.btn-calculate:hover { filter: brightness(1.06); box-shadow: 0 6px 16px -2px rgba(37, 99, 235, 0.5); }
.btn-calculate:active { transform: translateY(1px); }

/* --- Results Display --- */
.result-hero {
  text-align: center;
  padding: 24px 0 28px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 24px;
}

.result-hero .label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 8px;
}

.result-hero .amount {
  font-size: clamp(2.4rem, 3vw + 1rem, 3.2rem);
  font-weight: 800;
  color: var(--blue-dark);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.94rem;
}

.result-row:last-child { border-bottom: none; }
.result-row .label { color: var(--text-secondary); }
.result-row .value { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.result-row .value.highlight { color: #c2410c; }

/* --- Amortization Chart --- */
.chart-container { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border-light); }
.chart-container h3 { font-size: 0.95rem; font-weight: 600; color: var(--blue-dark); margin-bottom: 16px; }
.bar-chart { display: flex; height: 32px; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; box-shadow: inset 0 1px 2px rgba(0,0,0,0.06); }
.bar-principal { background: linear-gradient(180deg, var(--blue-mid), #1d4ed8); transition: width var(--dur-slow) var(--ease); }
.bar-interest { background: linear-gradient(180deg, var(--orange-accent), #c2410c); transition: width var(--dur-slow) var(--ease); }
.chart-legend { display: flex; gap: 20px; font-size: 0.82rem; color: var(--text-light); }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend-dot.principal { background: var(--blue-mid); }
.legend-dot.interest { background: var(--orange-accent); }

/* --- Amortization Table --- */
.amort-toggle {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 20px;
  background: var(--blue-pale);
  color: var(--blue-mid);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background var(--dur) var(--ease);
}
.amort-toggle:hover { background: var(--blue-border); }

.amort-table-wrap { display: none; margin-top: 16px; max-height: 400px; overflow-y: auto; border: 1px solid var(--border-light); border-radius: var(--radius); }
.amort-table-wrap.open { display: block; }
.amort-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.amort-table th { position: sticky; top: 0; background: var(--blue-dark); color: #fff; padding: 10px 10px; text-align: right; font-weight: 600; letter-spacing: 0.02em; }
.amort-table th:first-child { text-align: center; }
.amort-table td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border-light); color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.amort-table td:first-child { text-align: center; color: var(--text-light); }
.amort-table tbody tr:hover { background: var(--blue-pale); }

/* --- Widget Cards (homepage) --- */
.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.widget-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.widget-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid transparent;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.35), rgba(99, 102, 241, 0.35)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  pointer-events: none;
}

.widget-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: transparent;
}
.widget-card:hover::after { opacity: 1; }

/* Icon badge — SVG-based */
.widget-card .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--blue-tint);
  color: var(--blue-mid);
  margin-bottom: 14px;
  flex-shrink: 0;
}
.widget-card .icon svg { width: 22px; height: 22px; }

/* Category color variants */
.widget-card[data-cat="finance"] .icon { background: var(--green-tint); color: var(--green-confirm); }
.widget-card[data-cat="health"] .icon { background: var(--pink-tint); color: var(--pink-mid); }
.widget-card[data-cat="math"] .icon { background: var(--purple-tint); color: var(--purple-mid); }
.widget-card[data-cat="time"] .icon { background: var(--blue-tint); color: var(--blue-mid); }
.widget-card[data-cat="everyday"] .icon { background: var(--orange-pale); color: var(--orange-accent); }
.widget-card[data-cat="widget"] .icon { background: var(--teal-tint); color: var(--teal-mid); }

.widget-card h3 {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.015em;
}

.widget-card p {
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.55;
  flex-grow: 1;
}

.widget-card .tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 14px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #15803d;
  background: var(--green-pale);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  letter-spacing: 0.01em;
  align-self: flex-start;
}
.widget-card .tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-confirm);
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.15);
}

/* --- Category header --- */
.category-header {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: var(--max-width);
  margin: 0 auto 20px;
  padding: 0 0;
}
.category-header .cat-icon {
  display: inline-flex;
  width: 34px; height: 34px;
  align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--blue-tint);
  color: var(--blue-mid);
}
.category-header .cat-icon svg { width: 18px; height: 18px; }
.category-header h2 { font-size: 1.35rem; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.category-header .cat-count {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--text-light);
  font-weight: 500;
}

/* --- Section --- */
.section { padding: 64px 24px; }
.section-title {
  font-size: clamp(1.5rem, 1.5vw + 1rem, 2rem);
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  color: var(--text-primary);
  letter-spacing: -0.028em;
}
.section-subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 1rem;
  max-width: 560px;
  margin: 0 auto 40px;
  line-height: 1.55;
}

/* --- FAQ --- */
.faq-section { border-top: 1px solid var(--border-light); }
.faq-section .section-title { margin-bottom: 28px; }
.faq-item { border-top: 1px solid var(--border-light); padding: 22px 0; }
.faq-item:first-of-type { border-top: none; padding-top: 8px; }
.faq-q { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); margin: 0 0 8px; line-height: 1.4; letter-spacing: -0.015em; }
.faq-a { color: var(--text-secondary); font-size: 0.95rem; line-height: 1.7; margin: 0; }

/* --- Footer --- */
.site-footer {
  background: linear-gradient(180deg, #0f2846 0%, #0a1e39 100%);
  color: rgba(255,255,255,0.7);
  padding: 56px 24px 24px;
  margin-top: 56px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 32px;
}

.footer-col h4 {
  color: #fff;
  font-size: 0.85rem;
  margin-bottom: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.footer-col ul { list-style: none; }
.footer-col ul li { margin-bottom: 8px; }
.footer-col a { color: rgba(255,255,255,0.62); font-size: 0.88rem; transition: color var(--dur) var(--ease); }
.footer-col a:hover { color: #fff; }

.footer-bottom {
  max-width: var(--max-width);
  margin: 40px auto 0;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  text-align: center;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.65);
}

/* --- Embed Mode (strips chrome when loaded via ?embed=1) --- */
body.embed-mode { background: #fff; margin: 0; }
body.embed-mode .site-header,
body.embed-mode .hero-compact,
body.embed-mode .site-footer,
body.embed-mode .embed-section,
body.embed-mode .section { display: none !important; }

.embed-badge {
  display: none;
  text-align: center;
  padding: 10px 0;
  font-size: 0.78rem;
  color: var(--text-light);
}
.embed-badge a { color: var(--blue-mid); font-weight: 600; }
body.embed-mode .embed-badge { display: block; }

/* --- Embed Section --- */
.embed-section {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 24px 56px;
}
.embed-section .embed-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
}
.embed-section .embed-card h3 { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; letter-spacing: -0.015em; }
.embed-section .embed-card p { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 16px; }
.embed-section textarea {
  width: 100%;
  height: 100px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: var(--text-secondary);
  resize: vertical;
  background: var(--bg-off);
  line-height: 1.5;
}
.embed-section .copy-embed-btn {
  margin-top: 10px;
  padding: 10px 20px;
  background: var(--bg-white);
  color: var(--blue-mid);
  border: 1px solid var(--blue-border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.embed-section .copy-embed-btn:hover { background: var(--blue-pale); }

/* --- Utility: inline code --- */
code {
  background: var(--bg-tint);
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.9em;
  border: 1px solid var(--border-light);
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .calc-body { grid-template-columns: 1fr; }
  .calc-inputs {
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    padding: 28px 24px;
  }
  .calc-results { padding: 28px 24px; }
  .input-row { grid-template-columns: 1fr; }
  .hero-compact { padding: 56px 24px 80px; }
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 12px;
    right: 12px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 12px;
    gap: 2px;
    box-shadow: var(--shadow-lg);
    align-items: stretch;
  }
  .nav-links a { padding: 10px 12px; }
  .nav-links.open { display: flex; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .footer-inner { grid-template-columns: 1fr; text-align: left; }
  .widget-grid { grid-template-columns: 1fr; }
  .section { padding: 48px 20px; }
}

/* --- Motion preferences --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
