/* Global Site Styles */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem; /* 13px, a slight decrease from 14px (text-sm) */
    background-color: #f3f4f6;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main.content-wrapper {
    flex-grow: 1;
}

/* Page-Specific Calculator Styles */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
/* MODIFIED: Shortened animation and pointed to new keyframe */
details[open] summary ~ * { animation: sweep .3s ease-in-out; } 
/* MODIFIED: Removed transform from keyframe to prevent CLS */
@keyframes sweep { 0% { opacity: 0; } 100% { opacity: 1; } }

.tooltip-container { position: relative; display: inline-flex; align-items: center; }
.tooltip-icon { margin-left: 4px; cursor: help; color: #9ca3af; border: 1px solid #d1d5db; border-radius: 9999px; width: 14px; height: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: bold; }
.tooltip-text { visibility: hidden; width: 220px; background-color: #1f2937; color: #fff; text-align: center; border-radius: 6px; padding: 8px; position: absolute; z-index: 10; bottom: 125%; left: 50%; margin-left: -110px; opacity: 0; transition: opacity 0.3s; font-size: 12px; font-weight: normal; }
.tooltip-text::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #1f2937 transparent transparent transparent; }
.tooltip-container:hover .tooltip-text, .tooltip-container:focus-within .tooltip-text { visibility: visible; opacity: 1; }

#chartContainer, #rent-vs-buy-chart-container, #affordability-chart-container, #refinance-chart-container { position: relative; height: 200px; width: 100%; } /* Reduced from 250px */
@media (min-width: 640px) {
    #chartContainer, #rent-vs-buy-chart-container, #affordability-chart-container, #refinance-chart-container {
        height: 260px; /* Reduced from 320px */
    }
}
#amortizationTable th, #amortizationTable td { white-space: nowrap; }
#amortizationTable thead th {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    top: 0;
    z-index: 10;
}


/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.85);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem; /* rounded-lg */
    transition: opacity 0.3s ease-in-out;
}
.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid #d1d5db; /* gray-300 */
    border-bottom-color: #1C768F; /* primary */
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}
@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }


/* Mobile-first adjustments for the main calculator layout */
.main-grid-layout {
    display: grid;
    grid-template-columns: 1fr; /* Mobile: single column is the default */
    gap: 1rem;
}

.output-column {
    overflow: hidden; /* DEFINITIVE FIX: Prevents the child table from expanding the grid column */
}

@media (min-width: 768px) { /* Tablet and up */
    .main-grid-layout {
        grid-template-columns: repeat(5, minmax(0, 1fr)); /* 5-column grid for layout control */
    }
    .input-column {
        grid-column: span 2 / span 2; /* Takes up 2 of 5 columns */
    }
    .output-column {
        grid-column: span 3 / span 3; /* Takes up 3 of 5 columns */
    }
}

/* Amortization Schedule Container Style */
.schedule-container {
    max-height: 450px;
    overflow-y: auto;
    overflow-x: auto; /* This allows the table inside to scroll horizontally */
    -webkit-overflow-scrolling: touch; /* Adds momentum scrolling on iOS */
    position: relative;
}

/* Visual cue for horizontally scrolling table on touch devices */
@media (max-width: 768px) {
    .schedule-container::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 40px;
        background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
        pointer-events: none;
        z-index: 1;
    }
}

/* Tab Styles */
#main-tabs button {
    border-color: transparent;
    color: #4b5563; /* gray-600 */
    /* NEW: Add transition for smooth color/bg change */
    transition: all 0.2s ease-in-out;
    /* NEW: Set a consistent, thicker border width for all tabs */
    border-bottom-width: 4px; 
    /* NEW: Adjust margin to compensate for thicker border and keep alignment */
    margin-bottom: -2px; 
}
#main-tabs button.active {
    color: #1C768F; /* primary */
    border-color: #1C768F; /* primary */
    font-weight: 700; /* UPDATED: Bolder font */
    /* NEW: Add a distinct background color to the active tab */
    background-color: #f0f9ff; /* sky-50 */
}
#main-tabs button:hover {
    border-color: #d1d5db; /* gray-300 */
    color: #1f2937; /* gray-800 */
}
/* Mobile-friendly scrollable tabs */
.scrollable-tabs::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome, Safari and Opera */
}
.scrollable-tabs {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Quiz Option Selected Style */
.quiz-option.selected {
    border-color: #2C98C2;
    background-color: #f0f9ff; /* sky-50 */
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}


/* Accessibility Focus Styles */
:is(button, a, input, select, [tabindex="0"]):focus-visible {
    outline: 2px solid #38bdf8; /* sky-400 */
    outline-offset: 1px;
}

/* Make form elements smoother */
input, select {
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

/* Input Error Styling */
.input-error {
    border-color: #ef4444 !important; /* red-500 */
    box-shadow: 0 0 0 1px #ef4444;
}

.inline-error-message {
    color: #ef4444;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}


/* Visual Feedback Animation */
.flash-highlight {
    animation: flash 1s ease-out;
}
@keyframes flash {
    0% { background-color: transparent; }
    25% { background-color: rgba(245, 158, 11, 0.4); } /* amber-400 with opacity */
    100% { background-color: transparent; }
}

/* MODIFIED: Shortened animation */
.results-animate-in { animation: fadeInSlideUp 0.3s ease-out forwards; }
/* MODIFIED: Removed transform from keyframe to prevent CLS */
@keyframes fadeInSlideUp { 0% { opacity: 0; } 100% { opacity: 1; } }

/* ADVANCED CHARTING: Styles for chart toggle switches */
.toggle-checkbox:checked + .toggle-bg {
    background-color: #166534; /* accent color */
}
.toggle-checkbox:checked + .toggle-bg + .dot {
    transform: translateX(100%);
}

/* Custom Range Slider */
.range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  background: #e5e7eb; /* gray-200 */
  outline: none;
  opacity: 0.9;
  -webkit-transition: .2s;
  transition: opacity .2s;
  border-radius: 9999px;
}
.range-slider:hover {
  opacity: 1;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #2C98C2; /* New Accent Color */
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 5px rgba(0,0,0,0.2);
}
.range-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #2C98C2; /* New Accent Color */
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

/* Improved FAQ Styles */
.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

/* Modern Quiz Animations */
@keyframes question-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes question-fade-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-10px); }
}
.question-in { animation: question-fade-in 0.4s ease-out forwards; }
.question-out { animation: question-fade-out 0.3s ease-in forwards; }


/* UPDATED AND ENHANCED PRINT STYLES */
@media print {
    /* Hide non-essential elements */
    .no-print, header, footer, .input-column, #main-tabs, details > summary, #guide-content {
        display: none !important;
    }

    /* General page setup for printing */
    body {
        background-color: #fff;
        font-size: 10pt;
        color: #000;
        -webkit-print-color-adjust: exact; /* Force background colors for charts */
        print-color-adjust: exact;
    }

    /* Override layout to be single-column */
    .main-grid-layout {
        display: block !important;
    }

    .output-column, .calculator-container, main.content-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Reset styles for report-like appearance */
    #results, #schedule-wrapper, .calculator-container {
        box-shadow: none !important;
        border: none !important;
    }

    /* Ensure backgrounds are transparent for clean printing */
    .bg-gray-50, .bg-primary\/10, .bg-accent\/10, .bg-npv\/10, .bg-red-50\/50, .bg-sky-50\/50, .bg-sky-50\/70, .bg-red-50\/70 {
        background-color: transparent !important;
    }
    
    /* Force details sections to be open */
    details {
        page-break-inside: avoid;
    }
    
    details[open] {
        page-break-before: auto; /* Change from always to auto for better flow */
    }

    /* Control page breaks for a cleaner report */
    #results, #schedule-wrapper {
        page-break-inside: avoid;
    }
    #schedule-wrapper {
        page-break-before: always; /* Start the schedule on a new page */
    }
    
    /* Style chart containers for printing */
    #chartContainer, #rent-vs-buy-chart-container, #affordability-chart-container, #refinance-chart-container {
        height: 300px !important; /* A reasonable fixed height for print */
        width: 100% !important;
        page-break-inside: avoid;
    }

    /* Make amortization table headers readable */
    #amortizationTable thead {
        background-color: #f3f4f6 !important; /* A light gray for header */
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    #amortizationTable th {
        color: #000 !important;
    }

    /* Visually hide elements but keep for screen readers if needed */
    .visually-hidden {
        display: none;
    }
}

/* NEW GLOBAL WIDTH CLASS */
.container-global {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    max-width: 1150px;
    padding-left: 1rem; /* Replicates px-4 */
    padding-right: 1rem; /* Replicates px-4 */
}

@media (min-width: 640px) {
    .container-global {
        padding-left: 1.5rem; /* Replicates sm:px-6 */
        padding-right: 1.5rem; /* Replicates sm:px-6 */
    }
}

@media (min-width: 1024px) {
    .container-global {
        padding-left: 2rem; /* Replicates lg:px-8 */
        padding-right: 2rem; /* Replicates lg:px-8 */
    }
}

/* NEW: 75/25 Grid Layout for Blog Pages */
.blog-layout-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile-first: single column */
    gap: 1.5rem; /* 24px gap */
}

/* Desktop and tablet layout */
@media (min-width: 1024px) { /* lg: breakpoint */
    .blog-layout-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)); /* 4-column grid */
    }

    .blog-layout-grid > article {
        grid-column: span 3 / span 3; /* Article takes 3 of 4 columns (75%) */
        min-width: 0; /* Prevents overflow issues */
    }

    .blog-layout-grid > aside {
        grid-column: span 1 / span 1; /* Sidebar takes 1 of 4 columns (25%) */
        min-width: 0; /* Prevents overflow issues */
    }
}

/* NEW: 80/20 Grid Layout for Standalone Calculator Pages */
.calculator-layout-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile-first: single column */
    gap: 1.5rem; /* 24px gap */
}

/* Desktop and tablet layout */
@media (min-width: 1024px) { /* lg: breakpoint */
    .calculator-layout-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr)); /* 5-column grid for 80/20 split */
    }

    .calculator-layout-grid > main {
        grid-column: span 4 / span 4; /* Main content takes 4 of 5 columns (80%) */
        min-width: 0; /* Prevents overflow issues */
    }

    .calculator-layout-grid > aside {
        grid-column: span 1 / span 1; /* Sidebar takes 1 of 5 columns (20%) */
        min-width: 0; /* Prevents overflow issues */
    }
    
    /* Sticky sidebar for calculator pages */
    .calculator-layout-grid > aside > .sticky {
        position: sticky;
        top: 6rem; /* 96px, assumes 60px header + 24px margin + 12px padding */
    }
}

/* NEW: Styles for the Guided Planning Hub */

/* Styles for the quick access top links */
.quick-link-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    /* UPDATED: Reduced padding */
    padding: 0.5rem; /* p-2 */
    border-radius: 0.5rem;
    border-width: 2px;
    transition: all 0.2s ease-in-out;
}

.quick-link-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

/* Styles for the main guided path steps */
.path-details summary {
    user-select: none; /* Prevent text selection on click */
}
.path-details summary:hover {
    opacity: 0.95;
}

.path-details ol li {
    padding-left: 0; /* Remove default list padding */
    list-style: none;
    margin-left: 0;
}
.path-details ol li > div {
    border-left: 2px solid #e5e7eb; /* Light gray line for visual flow */
    padding-left: 0.75rem;
}
.path-details ol li:last-child > div {
    border-left: 2px solid transparent; /* Hide line for last item */
}

/* NEW: Added border glow effect */
.border-glow-primary {
    /* UPDATED: Made the glow effect more distinct */
    box-shadow: 0 0 15px rgba(28, 118, 143, 0.6), 0 2px 6px rgba(0,0,0,0.05);
}

/* SEO Content Section Styles */
.prose p, .prose ul, .content-section p, .content-section ul {
    margin-bottom: 1em;
    color: #374151;
}
.prose h1, .prose h2, .prose h3 {
    margin-bottom: 0.5em;
    color: #111827;
    font-weight: 700;
}

/* NEW: Global Blog Title Style (as requested) */
article > header > h1 {
    font-size: 26px;
    font-weight: 800; /* extra-bold */
    color: #1C768F; /* primary color */
    text-align: center;
    line-height: 1.2; /* Added for better spacing */
}

/* UPDATED: Centralized Blog Prose Heading Styles */
.prose h1 {
    font-size: 26px;
    font-weight: 800; /* extrabold */
    color: #1C768F; /* primary */
}
.prose h2 {
    font-size: 20px;
    font-weight: 700; /* bold */
    color: #1C768F; /* primary */
}
.prose h3 {
    font-size: 16px;
    font-weight: 600; /* semibold */
    color: #1f2937; /* gray-800 */
}

/* SEO Content Section Styles */
.content-fade-in {
    animation: fadeIn .7s ease-in-out;
}
@keyframes fadeIn { 0% { opacity: 0; } 100% { opacity: 1; } }

.content-section {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem;
    border-left: 4px solid #1C768F; /* NEW: Added primary color border */
}
@media (min-width: 640px) {
    .content-section {
        padding: 1.5rem;
    }
}

.sidebar-widget {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem;
}
.sidebar-title {
    font-size: 0.875rem; /* text-sm */
    font-weight: 700;
    color: #1C768F; /* Primary color */
    border-bottom: 2px solid #1C768F;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}

/* Visually Hidden Class */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Back to Top Button */
.back-to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #1C768F;
  color: white;
  border: none;
  border-radius: 50%;
  padding: 10px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  transition: opacity 0.3s, visibility 0.3s;
}

.back-to-top:hover {
  background-color: #166534;
}

/* Modern Mobile Related Articles */
.shadow-top-lg {
    box-shadow: 0 -4px 15px -3px rgb(0 0 0 / 0.1), 0 -2px 6px -4px rgb(0 0 0 / 0.1);
}

.mobile-article-card {
    display: block;
    flex-shrink: 0;
    width: 160px; /* w-40 */
    background-color: white;
    border: 1px solid #e5e7eb; /* gray-200 */
    border-radius: 0.75rem; /* rounded-lg */
    padding: 0.75rem; /* p-3 */
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); /* shadow-sm */
    transition: all 0.2s ease-in-out;
    text-align: center;
}

.mobile-article-card:hover {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); /* shadow-md */
    border-color: #1C768F; /* primary color */
    transform: translateY(-3px);
}

.mobile-article-card .flex {
    margin-left: auto;
    margin-right: auto;
}

/* NEW: Styles for calculator/blog cards on hub page */
.hub-card {
    display: block;
    position: relative;
    background-color: #ffffff; /* UPDATED: Changed to white */
    padding: 0.75rem; /* p-3 */
    border-radius: 0.5rem; /* rounded-lg */
    /* UPDATED: Changed border to be 2px and use a light primary color */
    border: 2px solid rgba(28, 118, 143, 0.2); /* 2px border-primary/20 */
    transition: all 0.2s ease-in-out;
}
.hub-card:hover {
    border-color: #1C768F; /* hover:border-primary */
    background-color: #f0f9ff; /* hover:bg-sky-50 */
    transform: translateY(-2px);
    /* UPDATED: Added a glow effect using the primary color */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05), 0 0 15px rgba(28, 118, 143, 0.3);
}