/* ============================================================
   CalcBright — Shared Stylesheet
   Light mode only. Poppins self-hosted (eliminates CLS).
   ============================================================ */

/* ---------- Self-hosted Poppins (no Google Fonts request) ---------- */
@font-face {
    font-family: 'Poppins';
    src: url('fonts/poppins-300.woff2') format('woff2');
    font-weight: 300;
    font-style: normal;
    font-display: optional;
}
@font-face {
    font-family: 'Poppins';
    src: url('fonts/poppins-400.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: optional;
}
@font-face {
    font-family: 'Poppins';
    src: url('fonts/poppins-500.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: optional;
}
@font-face {
    font-family: 'Poppins';
    src: url('fonts/poppins-600.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: optional;
}
@font-face {
    font-family: 'Poppins';
    src: url('fonts/poppins-700.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: optional;
}
@font-face {
    font-family: 'Poppins';
    src: url('fonts/poppins-800.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: optional;
}

/* ---------- Reset & Variables ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary:        #4F46E5;
    --primary-dark:   #4338CA;
    --primary-light:  #EEF2FF;
    --secondary:      #06B6D4;
    --success:        #10B981;
    --warning:        #F59E0B;
    --danger:         #EF4444;
    --bg:             #F8FAFC;
    --white:          #FFFFFF;
    --text:           #1F2937;
    --text-muted:     #6B7280;
    --border:         #E5E7EB;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
    --shadow-md:      0 4px 12px rgba(0,0,0,.08);
    --shadow-lg:      0 10px 30px rgba(0,0,0,.10);
    --radius-sm:      6px;
    --radius-md:      10px;
    --radius-lg:      14px;
    --max-width:      1200px;
    --transition:     0.25s ease;
}

/* Fallback font sized to match Poppins — eliminates layout shift (CLS) */
@font-face {
    font-family: 'Poppins-fallback';
    src: local('Arial');
    size-adjust: 105%;
    ascent-override: 105%;
    descent-override: 35%;
    line-gap-override: 0%;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Poppins', 'Poppins-fallback', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }

/* ---------- Typography ---------- */
h1 { font-size: clamp(1.9rem, 4vw, 2.75rem); font-weight: 800; line-height: 1.15; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem);    font-weight: 700; line-height: 1.2; }
h3 { font-size: 1.25rem; font-weight: 600; }

/* ---------- Layout ---------- */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

.section-pad { padding: 4rem 0; }

/* ---------- Header / Nav ---------- */
.site-header {
    background: var(--white);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 200;
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.logo-mark {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    list-style: none;
}

.nav-links a {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color var(--transition);
    white-space: nowrap;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
    color: var(--primary);
}

/* Hamburger */
.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: all var(--transition);
}

@media (max-width: 768px) {
    .nav-toggle { display: flex; }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        padding: 1rem 1.5rem 1.5rem;
        gap: 0.75rem;
        box-shadow: var(--shadow-md);
        border-top: 1px solid var(--border);
    }

    .nav-links.open { display: flex; }

    .site-header { position: relative; }
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    padding: 0.75rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.breadcrumb ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.breadcrumb li + li::before {
    content: "/";
    margin-right: 0.35rem;
    color: var(--border);
}

.breadcrumb a { color: var(--primary); }
.breadcrumb a:hover { text-decoration: underline; }

/* ---------- Hero (Homepage) ---------- */
.hero {
    background: linear-gradient(135deg, #F0F4FF 0%, #E0E7FF 100%);
    padding: 5rem 1.5rem;
    text-align: center;
}

.hero-content { max-width: 760px; margin: 0 auto; }

.hero-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    margin-bottom: 1.25rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.hero h1 { margin-bottom: 1.25rem; color: var(--text); }

.hero p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 580px;
    margin: 0 auto 2rem;
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.8rem 1.75rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(79,70,229,.28);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--white);
}

.btn-sm {
    padding: 0.55rem 1.2rem;
    font-size: 0.875rem;
}

.btn-block { width: 100%; }

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ---------- Tool Cards (homepage grid) ---------- */
.tools-section { padding: 4rem 0; }

.section-title {
    text-align: center;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 3rem;
    font-size: 1rem;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.tool-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
    min-height: 180px;
    contain: layout;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.tool-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.tool-icon.grade      { background: linear-gradient(135deg,#4F46E5,#7C3AED); }
.tool-icon.tip        { background: linear-gradient(135deg,#06B6D4,#0891B2); }
.tool-icon.percentage { background: linear-gradient(135deg,#10B981,#059669); }
.tool-icon.loan       { background: linear-gradient(135deg,#F59E0B,#D97706); }
.tool-icon.password   { background: linear-gradient(135deg,#EF4444,#DC2626); }

.tool-card h3 { font-size: 1.15rem; color: var(--text); }
.tool-card p  { font-size: 0.9rem;  color: var(--text-muted); flex: 1; }

.tool-card-arrow {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-top: 0.5rem;
}

/* ---------- Features strip ---------- */
.features-strip {
    background: var(--white);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 3rem 0;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 2rem;
    text-align: center;
}

.feature-item { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }

.feature-icon-wrap {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.feature-item h4 { font-size: 0.95rem; font-weight: 600; }
.feature-item p  { font-size: 0.82rem; color: var(--text-muted); }

/* ---------- Calculator Page Header ---------- */
.calc-page-hero {
    background: linear-gradient(135deg, #F0F4FF 0%, #E0E7FF 60%);
    padding: 3rem 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
}

.calc-page-hero h1 { margin-bottom: 0.6rem; }
.calc-page-hero p  { color: var(--text-muted); font-size: 1rem; max-width: 600px; }

/* ---------- Calculator Layout ---------- */
.calc-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 2rem;
    padding: 2.5rem 0 4rem;
    align-items: start;
}

@media (max-width: 960px) {
    .calc-layout { grid-template-columns: 1fr; }
}

/* ---------- Calculator Card ---------- */
.calc-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    padding: 2rem;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.4rem; }

.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: 'Poppins', sans-serif;
    color: var(--text);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: auto;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.form-control.is-invalid { border-color: var(--danger); }

.form-error {
    display: none;
    font-size: 0.8rem;
    color: var(--danger);
    margin-top: 0.3rem;
}

.form-control.is-invalid + .form-error { display: block; }

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.75rem;
    align-items: end;
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.input-row.cols-3 { grid-template-columns: 1fr 1fr auto; }
.input-row.cols-2 { grid-template-columns: 1fr 1fr; }

@media (max-width: 600px) {
    .input-row,
    .input-row.cols-3 { grid-template-columns: 1fr; }
}

/* Tip quick-select buttons */
.tip-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.btn-preset {
    padding: 0.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-family: 'Poppins', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-muted);
}

.btn-preset:hover,
.btn-preset.active {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* Checkboxes / password options */
.checkbox-group { display: flex; flex-direction: column; gap: 0.6rem; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

/* Range slider */
.range-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.range-row input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
    height: 4px;
    cursor: pointer;
}

.range-value {
    font-weight: 700;
    color: var(--primary);
    min-width: 2.5rem;
    text-align: right;
    font-size: 1.1rem;
}

/* ---------- Add / Remove buttons ---------- */
.btn-add {
    background: none;
    border: 2px dashed var(--success);
    color: var(--success);
    border-radius: var(--radius-sm);
    padding: 0.55rem 1.2rem;
    font-family: 'Poppins', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 0.5rem;
}

.btn-add:hover {
    background: var(--success);
    color: var(--white);
    border-style: solid;
}

.btn-remove {
    background: none;
    border: 2px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    align-self: flex-end;
}

.btn-remove:hover {
    background: var(--danger);
    color: var(--white);
}

/* ---------- Result Box ---------- */
.result-box {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-lg);
    padding: 2rem;
    color: var(--white);
    text-align: center;
    margin-top: 2rem;
    animation: fadeSlideUp 0.3s ease;
}

.result-label {
    font-size: 0.9rem;
    opacity: 0.85;
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.result-value {
    font-size: clamp(2rem, 6vw, 3.25rem);
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.75rem;
}

.result-details {
    font-size: 0.92rem;
    opacity: 0.92;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-top: 1px solid rgba(255,255,255,.2);
}

.result-row:first-child { border-top: none; }

.result-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.result-actions .btn { flex: 1; min-width: 120px; }

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Error / validation toast ---------- */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--danger);
    color: var(--white);
    padding: 0.9rem 1.4rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    max-width: 320px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Grade Scale Table ---------- */
.table-wrap { overflow-x: auto; margin-top: 1.5rem; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

thead th {
    background: var(--bg);
    font-weight: 600;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
    color: var(--text);
    white-space: nowrap;
}

tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
}

tbody tr:hover td { background: var(--bg); color: var(--text); }

/* ---------- Sidebar ---------- */
.sidebar { display: flex; flex-direction: column; gap: 1.5rem; }

.sidebar-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.sidebar-card h3 { font-size: 1rem; margin-bottom: 1rem; }

.related-links { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }

.related-links a {
    font-size: 0.875rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: gap var(--transition);
}

.related-links a:hover { gap: 0.6rem; text-decoration: underline; }

/* ---------- FAQ Section ---------- */
.faq-section { padding: 4rem 0; }

.faq-list { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; }

.faq-item {
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
}

.faq-question {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 1.1rem 1.4rem;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: background var(--transition);
}

.faq-question:hover { background: var(--bg); }

.faq-question[aria-expanded="true"] { color: var(--primary); }

.faq-chevron {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    transition: transform var(--transition);
}

.faq-question[aria-expanded="true"] .faq-chevron { transform: rotate(180deg); }

.faq-answer {
    display: none;
    padding: 0 1.4rem 1.1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.faq-answer.open { display: block; }

/* ---------- Password display ---------- */
.password-display {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    word-break: break-all;
    letter-spacing: 0.04em;
    padding: 1rem;
    background: rgba(255,255,255,.15);
    border-radius: var(--radius-sm);
    margin: 0.75rem 0;
}

.strength-bar-wrap {
    height: 6px;
    background: rgba(255,255,255,.3);
    border-radius: 99px;
    overflow: hidden;
    margin: 0.75rem 0 0.4rem;
}

.strength-bar {
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease, background 0.4s ease;
}

/* ---------- Type tabs (grade calc) ---------- */
.tab-group {
    display: flex;
    gap: 0.4rem;
    background: var(--bg);
    padding: 0.35rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
}

.tab-btn {
    flex: 1;
    min-width: max-content;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    font-family: 'Poppins', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.tab-btn.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* ---------- Footer ---------- */
.site-footer {
    background: #111827;
    color: #D1D5DB;
    padding: 3.5rem 0 2rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr repeat(3, 1fr);
    gap: 2.5rem;
    margin-bottom: 3rem;
}

@media (max-width: 768px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .footer-grid { grid-template-columns: 1fr; }
}

.footer-brand .logo { color: var(--white); margin-bottom: 0.75rem; }
.footer-brand p { font-size: 0.85rem; line-height: 1.7; max-width: 240px; }

.footer-col h4 {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--white);
    margin-bottom: 1rem;
}

.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }

.footer-col a {
    font-size: 0.875rem;
    color: #9CA3AF;
    transition: color var(--transition);
}

.footer-col a:hover { color: var(--white); }

.footer-bottom {
    border-top: 1px solid #374151;
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.82rem;
    color: #6B7280;
}

/* ---------- Accessibility ---------- */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border-width: 0;
}

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 3px;
    border-radius: 3px;
}

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
