/* ============================================
   Islamic Finance UK — Main Stylesheet
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --color-primary: #1B4332;
  --color-primary-dark: #0f2a1f;
  --color-primary-light: #2d6a4f;
  --color-accent: #D4A017;
  --color-accent-light: #f0c040;
  --color-white: #ffffff;
  --color-bg: #F8F9FA;
  --color-text: #212529;
  --color-text-muted: #6c757d;
  --color-border: #dee2e6;
  --color-best-rate: #FFF3CD;
  --color-excluded: #fff0f0;
  --color-error: #dc3545;
  --color-success: #198754;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.16);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: 0.25s ease;
  --font-main: 'Inter', sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body { font-family: var(--font-main); color: var(--color-text); background: var(--color-white); line-height: 1.6; }
img { max-width: 100%; display: block; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-light); }
ul { list-style: none; }

/* --- Typography --- */
h1, h2, h3, h4, h5 { font-weight: 700; line-height: 1.25; color: var(--color-primary); }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2vw, 1.4rem); }
p { margin-bottom: 1rem; }
.text-muted { color: var(--color-text-muted); }
.text-accent { color: var(--color-accent); }
.text-center { text-align: center; }

/* --- Layout Utilities --- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }
.section { padding: 4rem 0; }
.section--bg { background: var(--color-bg); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 1rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.7rem 1.6rem; border-radius: var(--radius-sm);
  font-family: var(--font-main); font-size: 0.95rem; font-weight: 600;
  cursor: pointer; border: 2px solid transparent;
  transition: all var(--transition); text-decoration: none; white-space: nowrap;
}
.btn-primary {
  background: var(--color-accent); color: var(--color-primary-dark);
  border-color: var(--color-accent);
}
.btn-primary:hover {
  background: var(--color-accent-light); border-color: var(--color-accent-light);
  color: var(--color-primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md);
}
.btn-secondary {
  background: transparent; color: var(--color-white);
  border-color: var(--color-white);
}
.btn-secondary:hover {
  background: var(--color-white); color: var(--color-primary);
  transform: translateY(-1px); box-shadow: var(--shadow-md);
}
.btn-outline {
  background: transparent; color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline:hover {
  background: var(--color-primary); color: var(--color-white);
}

/* --- Navbar --- */
.navbar {
  position: sticky; top: 0; z-index: 1000;
  background: var(--color-primary);
  box-shadow: none;
  transition: box-shadow var(--transition);
}
.navbar.scrolled { box-shadow: var(--shadow-lg); }
.navbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.25rem; max-width: 1200px; margin: 0 auto;
}
.navbar__logo {
  font-size: 1.25rem; font-weight: 800; color: var(--color-white);
  letter-spacing: -0.5px; display: flex; align-items: center; gap: 0.5rem;
}
.navbar__logo span { color: var(--color-accent); }
.navbar__logo:hover { color: var(--color-white); }
.navbar__links {
  display: flex; align-items: center; gap: 0.25rem;
}
.navbar__links a {
  color: rgba(255,255,255,0.85); padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500;
  transition: all var(--transition);
}
.navbar__links a:hover, .navbar__links a.active {
  color: var(--color-white); background: rgba(255,255,255,0.12);
}
.navbar__toggle {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.navbar__toggle span {
  display: block; width: 24px; height: 2px;
  background: var(--color-white); border-radius: 2px;
  transition: all var(--transition);
}
.navbar__toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.navbar__toggle.open span:nth-child(2) { opacity: 0; }
.navbar__toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* --- Hero --- */
.hero {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 60%, var(--color-primary-light) 100%);
  color: var(--color-white); padding: 5rem 1.25rem 4rem; text-align: center;
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero__content { position: relative; max-width: 700px; margin: 0 auto; }
.hero h1 { color: var(--color-white); margin-bottom: 1rem; }
.hero p { font-size: 1.15rem; color: rgba(255,255,255,0.85); margin-bottom: 2rem; }
.hero__cta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* --- Cards --- */
.card {
  background: var(--color-white); border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm); padding: 1.75rem;
  border: 1px solid var(--color-border);
  transition: transform var(--transition), box-shadow var(--transition);
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.card__icon {
  width: 52px; height: 52px; border-radius: var(--radius-sm);
  background: var(--color-bg); display: flex; align-items: center;
  justify-content: center; font-size: 1.5rem; margin-bottom: 1rem;
}
.card__title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.5rem; }
.card__desc { color: var(--color-text-muted); font-size: 0.9rem; margin-bottom: 0; }
.card--link { cursor: pointer; }
.card--link:hover .card__title { color: var(--color-primary-light); }

/* --- Section Headers --- */
.section-header { text-align: center; margin-bottom: 2.5rem; }
.section-header h2 { margin-bottom: 0.5rem; }
.section-header p { color: var(--color-text-muted); max-width: 600px; margin: 0 auto; }
.section-header .divider {
  width: 60px; height: 4px; background: var(--color-accent);
  border-radius: 2px; margin: 0.75rem auto 0;
}

/* --- Tables --- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  background: var(--color-primary); color: var(--color-white);
  padding: 0.85rem 1rem; text-align: left; font-weight: 600;
  white-space: nowrap;
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
tbody tr { border-bottom: 1px solid var(--color-border); transition: background var(--transition); }
tbody tr:nth-child(even) { background: var(--color-bg); }
tbody tr:hover { background: #e8f5e9; }
tbody td { padding: 0.8rem 1rem; vertical-align: middle; }
tbody tr.best-rate { background: var(--color-best-rate) !important; font-weight: 600; }
tbody tr.best-rate td:first-child::after {
  content: ' ⭐ Best Rate'; font-size: 0.75rem; color: var(--color-accent);
  font-weight: 700; margin-left: 0.4rem;
}
tbody tr.excluded { background: var(--color-excluded) !important; }
tbody tr.excluded .stock-name { text-decoration: line-through; color: var(--color-text-muted); }

/* --- Badges --- */
.badge {
  display: inline-block; padding: 0.2rem 0.55rem; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-grey { background: #f3f4f6; color: #374151; }

/* ============================================
   Email Signup Banner
   ============================================ */
.signup-banner {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  padding: 3rem 1.25rem;
  color: var(--color-white);
}
.signup-banner__inner {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto; gap: 1.5rem 3rem;
  align-items: center;
}
.signup-banner__text h2 {
  color: var(--color-white); font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  margin-bottom: 0.4rem;
}
.signup-banner__text p {
  color: rgba(255,255,255,0.85); font-size: 0.95rem; margin: 0;
}
.signup-form {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  grid-column: 2; align-self: center;
}
.signup-form input[type="email"] {
  padding: 0.7rem 1rem; border: 2px solid rgba(255,255,255,0.4);
  border-radius: var(--radius-sm); background: rgba(255,255,255,0.12);
  color: var(--color-white); font-family: var(--font-main); font-size: 0.95rem;
  min-width: 240px; transition: border-color var(--transition);
}
.signup-form input[type="email"]::placeholder { color: rgba(255,255,255,0.6); }
.signup-form input[type="email"]:focus {
  outline: none; border-color: var(--color-accent);
  background: rgba(255,255,255,0.18);
}
.signup-note {
  grid-column: 1 / -1; font-size: 0.75rem;
  color: rgba(255,255,255,0.55); margin: 0;
}
.signup-note a { color: rgba(255,255,255,0.75); text-decoration: underline; }

/* ============================================
   Global Mobile Fixes
   ============================================ */

/* Ensure all table wrappers scroll on small screens */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Prevent table cells from being too narrow */
table { min-width: 560px; }

/* Navbar mobile — ensure toggle is always visible on small screens */
@media (max-width: 768px) {
  .navbar__toggle { display: flex; }
  .navbar__links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--color-primary-dark);
    padding: 0.75rem 1rem;
    gap: 0.2rem;
    box-shadow: var(--shadow-lg);
    z-index: 999;
  }
  .navbar__links.open { display: flex; }
  .navbar { position: relative; }
  .navbar__links a {
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
  }

  /* Signup banner stacks on mobile */
  .signup-banner__inner {
    grid-template-columns: 1fr;
  }
  .signup-form {
    grid-column: 1;
    flex-direction: column;
  }
  .signup-form input[type="email"] {
    min-width: 0; width: 100%;
  }
  .signup-form .btn { width: 100%; }
}

@media (max-width: 480px) {
  /* Hero CTA buttons stack */
  .hero__cta { flex-direction: column; align-items: center; }
  .hero__cta .btn { width: 100%; max-width: 280px; }

  /* Section padding tighter on very small screens */
  .section { padding: 2.5rem 0; }
  .hero { padding: 3rem 1rem 2.5rem; }
}

/* ============================================
   Welcome Modal
   ============================================ */
.welcome-modal {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.3s ease;
}
.welcome-modal[hidden] { display: none; }
.welcome-modal--visible { opacity: 1; }
.welcome-modal--closing { opacity: 0; }
.welcome-modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
}
.welcome-modal__card {
  position: relative; z-index: 1;
  background: var(--color-white); border-radius: var(--radius-lg);
  padding: 2.5rem 2rem; max-width: 520px; width: 90%;
  box-shadow: var(--shadow-lg); outline: none;
  animation: modalSlideUp 0.4s ease;
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.welcome-modal__close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; font-size: 1.6rem;
  color: var(--color-text-muted); cursor: pointer;
  width: 36px; height: 36px; display: flex; align-items: center;
  justify-content: center; border-radius: 50%;
  transition: background var(--transition), color var(--transition);
}
.welcome-modal__close:hover { background: var(--color-bg); color: var(--color-text); }
.welcome-modal__card h2 {
  font-size: 1.4rem; color: var(--color-primary); margin-bottom: 1rem;
}
.welcome-modal__card p {
  font-size: 0.9rem; color: var(--color-text); line-height: 1.6; margin-bottom: 0.75rem;
}
.welcome-modal__actions {
  display: flex; gap: 0.75rem; margin-top: 1.5rem; flex-wrap: wrap;
}
@media (max-width: 480px) {
  .welcome-modal__card { padding: 1.75rem 1.25rem; }
  .welcome-modal__actions { flex-direction: column; }
  .welcome-modal__actions .btn { width: 100%; }
}

/* Freshness badge (shared) */
.freshness-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 600;
  color: var(--color-text-muted); background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: 20px;
  padding: 0.2rem 0.7rem; margin-top: 0.5rem;
}

/* ============================================
   Layout Consistency — Internal Pages
   ============================================ */

/* Standard page container widths */
.container--utility { max-width: 960px; margin: 0 auto; padding: 0 1.25rem; }
.container--reading { max-width: 760px; margin: 0 auto; padding: 0 1.25rem; }

/* Consistent page hero (centred title + intro) */
.page-hero { text-align: center; }
.page-hero h1 { margin-left: auto; margin-right: auto; }
.page-hero p { margin-left: auto; margin-right: auto; }

/* Consistent section spacing */
.guide-section { margin-bottom: 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid var(--color-border); }
.guide-section:last-child { border-bottom: none; margin-bottom: 0; }

/* Internal page main content — left aligned within centred container */
.section .container { text-align: left; }

/* Consistent card grid alignment */
.grid-2, .grid-3, .grid-4 { margin-left: 0; margin-right: 0; }

/* Consistent filter bar alignment */
.filter-bar, .invest-filters, .stocks-filters { justify-content: flex-start; }

/* Consistent table wrapper */
.table-wrapper { margin-left: 0; margin-right: 0; }

/* Vertical rhythm between major sections */
.section + .section { margin-top: 0; }
.section { padding: 3.5rem 0; }
.section--bg + .section--bg { padding-top: 2rem; }

/* ============================================
   Mobile Usability Fixes (small screens)
   ============================================ */

@media (max-width: 768px) {

  /* Prevent any horizontal overflow */
  html, body { overflow-x: hidden; }

  /* Tables: ensure wrapper scrolls, not the page */
  .table-wrapper { max-height: none; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 480px; font-size: 0.82rem; }
  thead th { padding: 0.65rem 0.6rem; font-size: 0.78rem; }
  tbody td { padding: 0.6rem; }

  /* Buttons: minimum tap target 44px */
  .btn, .toggle-btn, .contrib-type-btn, .growth-card, .stat-card--selectable,
  .apply-link, .invest-card__link, .btn-show-more {
    min-height: 44px;
  }

  /* Navbar hamburger: ensure visible and tappable */
  .navbar__toggle { display: flex; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; }

  /* Cards: single column stacking */
  .grid-2, .grid-3, .grid-4, .quick-start { grid-template-columns: 1fr; }
  .screening-cards { grid-template-columns: 1fr; }

  /* Hero: tighter padding */
  .hero { padding: 3rem 1rem 2.5rem; }
  .page-hero { padding: 2.5rem 1rem 2rem; }
  .page-hero h1 { font-size: 1.5rem; }

  /* Modals: fit within viewport */
  .welcome-modal__card, .forecast-modal__content {
    max-width: 95vw; max-height: 90vh; overflow-y: auto;
    padding: 1.5rem 1.25rem;
  }
  .welcome-modal__card h2, .forecast-modal__title { font-size: 1.2rem; }

  /* Forms and filters: full width, comfortable size */
  .filter-select, .calc-input, input[type="number"], input[type="search"] {
    font-size: 16px; /* prevents iOS zoom on focus */
    min-height: 44px; padding: 0.6rem 0.75rem;
  }
  .input-prefix, .input-suffix, .input-prefix--compact {
    width: 100%; max-width: 100%;
  }
  .input-prefix--compact { width: 100%; }

  /* Invest toggle: full width on mobile */
  .invest-toggle { display: flex; width: 100%; }
  .invest-toggle__btn { flex: 1; text-align: center; padding: 0.7rem 0.5rem; }

  /* Contribution type buttons: stack */
  .contrib-type-btns { grid-template-columns: 1fr; }

  /* Growth cards: stack */
  .growth-cards, .growth-cards--3 { grid-template-columns: 1fr; }

  /* Age row: wrap naturally */
  .relief-age-row { flex-wrap: wrap; gap: 0.75rem; }
  .relief-age-sep { display: none; }
  .age-input { width: 100%; max-width: 120px; }

  /* Employer toggle row: stack */
  .employer-toggle-row { flex-direction: column; align-items: flex-start; gap: 0.75rem; }

  /* Sticky results bar: compact */
  .sticky-results { padding: 0.6rem 0.75rem; }
  .sticky-results__inner { gap: 0.4rem; }
  .sticky-item { flex: 1 1 45%; text-align: center; }
  .sticky-label { font-size: 0.6rem; }
  .sticky-value { font-size: 0.95rem; }

  /* Footer: single column */
  .footer__inner { grid-template-columns: 1fr; gap: 1.5rem; }

  /* Signup banner: stack */
  .signup-banner__inner { grid-template-columns: 1fr; }
  .signup-form { flex-direction: column; }
  .signup-form input[type="email"] { min-width: 0; width: 100%; }
  .signup-form .btn { width: 100%; }

  /* Trust bar: wrap */
  .trust-bar__inner { gap: 0.75rem; justify-content: center; }

  /* Designed for: stack */
  .designed-for__list { flex-direction: column; align-items: center; }

  /* Calculator: single column */
  .calc-layout { grid-template-columns: 1fr; }
  .result-cards { grid-template-columns: 1fr; }

  /* Relief result grid */
  .relief-result-grid, .relief-result-grid--3 { grid-template-columns: 1fr; }

  /* Milestone cards */
  .milestone-cards { grid-template-columns: 1fr; }

  /* TOC bar: scroll horizontally */
  .toc-bar .container { overflow-x: auto; flex-wrap: nowrap; }
  .toc-bar a { flex-shrink: 0; }

  /* Mini summary card: readable */
  .mini-summary-card { font-size: 0.95rem; padding: 1rem; }

  /* Lump sum box */
  .lump-sum-box { padding: 1rem 1.25rem; }
  .lump-sum-box__value { font-size: 1.6rem; }

  /* Step blocks: tighter padding */
  .step-block { padding: 1.25rem; }

  /* Provider cards in pension pages */
  .provider-cards { grid-template-columns: 1fr; }
  .sipp-cards { grid-template-columns: 1fr; }
}

/* Extra small screens (below 380px) */
@media (max-width: 380px) {
  .hero h1 { font-size: 1.4rem; }
  .stat-card__rate { font-size: 1.8rem; }
  .navbar__logo { font-size: 1rem; }
  .sticky-results__inner { flex-wrap: wrap; }
  .sticky-item { flex: 1 1 100%; }
}

/* ============================================
   Quick Wins — Next Steps, Footer, Back to Top
   ============================================ */

/* Next steps box (pension page) */
.next-steps-box {
  margin-top: 1.5rem; padding: 1.5rem;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); animation: fadeIn 0.6s ease;
}
.next-steps-box__title { font-size: 1rem; font-weight: 700; color: var(--color-primary); margin-bottom: 1rem; }
.next-steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.next-step-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 1rem; background: var(--color-white); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); text-decoration: none; color: var(--color-text);
  transition: all 0.25s ease; gap: 0.5rem;
}
.next-step-card:hover { border-color: var(--color-primary); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.next-step-card__icon { font-size: 1.5rem; }
.next-step-card__text { font-size: 0.82rem; font-weight: 600; }
@media (max-width: 640px) { .next-steps-grid { grid-template-columns: 1fr; } }

/* Footer founder line */
.footer__founder { font-size: 0.78rem; color: rgba(255,255,255,0.4); margin-top: 0.4rem; }

/* Prominent freshness badge */
.freshness-badge--prominent {
  display: block; font-size: 0.78rem; font-weight: 600;
  color: #92400e; background: #fef3c7;
  border: 1px solid #f59e0b; border-radius: var(--radius-sm);
  padding: 0.4rem 0.85rem; margin-top: 0.75rem;
}

/* Back to top button */
.back-to-top {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 800;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--color-primary); color: var(--color-white);
  border: none; font-size: 1.2rem; cursor: pointer;
  box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: flex; align-items: center; justify-content: center;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { transform: scale(1.1); }

/* Footer feedback link */
.footer__feedback { font-size: 0.8rem; color: rgba(255,255,255,0.5); margin-top: 0.4rem; }
.footer__feedback a { color: var(--color-accent); text-decoration: underline; }
.footer__feedback a:hover { color: var(--color-white); }
