/* ==================================================
   CFE Tools Hub
   Light + Dark mode
   Dark mode is the default.
================================================== */

:root {
    --cfe-red: #c9202f;

    --black: #111111;
    --charcoal: #1c1c1c;
    --dark-gray: #333333;
    --mid-gray: #777777;
    --light-gray: #d9d9d9;
    --lighter-gray: #e9e9e9;
    --off-white: #f6f6f6;
    --white: #ffffff;

    --page-width: 1200px;

    /* Theme colors - dark by default */
    --page-bg: #111111;
    --surface: #181818;
    --surface-hover: #1d1d1d;
    --header-bg: #151515;
    --footer-bg: #151515;

    --text-primary: #f2f2f2;
    --text-secondary: #9b9b9b;

    --border: #303030;
    --border-hover: #6b6b6b;

    --icon-bg: #2a2a2a;
    --icon-text: #f4f4f4;

    --shadow: rgba(0, 0, 0, 0.28);
}


/* ==================================================
   Light Theme
   Existing light-mode styling is preserved.
================================================== */

html[data-theme="light"] {
    --page-bg: var(--off-white);
    --surface: var(--white);
    --surface-hover: var(--white);
    --header-bg: var(--white);
    --footer-bg: var(--white);

    --text-primary: var(--black);
    --text-secondary: var(--mid-gray);

    --border: var(--light-gray);
    --border-hover: var(--dark-gray);

    --icon-bg: var(--charcoal);
    --icon-text: var(--white);

    --shadow: rgba(0, 0, 0, 0.05);
}


/* ==================================================
   Reset / Base
================================================== */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
}

body {
    margin: 0;

    font-family:
        "Montserrat",
        "Segoe UI",
        Arial,
        Helvetica,
        sans-serif;

    background: var(--page-bg);
    color: var(--text-primary);

    transition:
        background-color 180ms ease,
        color 180ms ease;
}

.container {
    width: min(90%, var(--page-width));
    margin: 0 auto;
}


/* ==================================================
   Header
================================================== */

.site-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);

    transition:
        background-color 180ms ease,
        border-color 180ms ease;
}

.header-content {
    min-height: 76px;

    display: flex;
    align-items: center;
    gap: 20px;
}


/* ==================================================
   Theme Toggle
================================================== */

.theme-toggle {
    width: 40px;
    height: 40px;

    flex: 0 0 40px;

    display: grid;
    place-items: center;

    padding: 0;

    background: transparent;
    color: var(--text-primary);

    border: 1px solid var(--border);
    border-radius: 50%;

    cursor: pointer;

    transition:
        color 180ms ease,
        border-color 180ms ease,
        background-color 180ms ease,
        transform 180ms ease;
}

.theme-toggle:hover {
    border-color: var(--cfe-red);
    color: var(--cfe-red);
    transform: translateY(-1px);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--cfe-red);
    outline-offset: 3px;
}

.theme-icon {
    grid-area: 1 / 1;

    font-size: 1.1rem;
    line-height: 1;

    transition:
        opacity 160ms ease,
        transform 220ms ease;
}

/* Dark mode shows the sun because clicking it switches to light mode. */
.sun-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.moon-icon {
    opacity: 0;
    transform: rotate(-20deg) scale(0.7);
}

html[data-theme="light"] .sun-icon {
    opacity: 0;
    transform: rotate(20deg) scale(0.7);
}

html[data-theme="light"] .moon-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}


/* ==================================================
   Branding
================================================== */

.brand {
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;

    min-width: 74px;
    height: 42px;

    padding: 0 12px;

    background: var(--icon-bg);
    color: var(--icon-text);

    border-radius: 3px;

    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.08em;

    transition:
        background-color 180ms ease,
        color 180ms ease;
}

.cfe-logo {
	display: block;
    width: 90px;
    height: auto;
    filter: invert(1);
}

html[data-theme="light"] .cfe-logo {
	display: block;
    width: 90px;
    height: auto;
    filter: none;
}

.brand-divider {
    width: 1px;
    height: 28px;

    background: var(--border);

    transition: background-color 180ms ease;
}

.site-name {
    color: var(--text-secondary);

    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.28em;

    transition: color 180ms ease;
}


/* ==================================================
   Intro
================================================== */

.intro {
    padding: 72px 0 34px;
}

.eyebrow {
    margin: 0 0 12px;

    color: var(--text-secondary);

    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.18em;

    transition: color 180ms ease;
}

.intro h1 {
    margin: 0 0 10px;

    color: var(--text-primary);

    font-size: clamp(2.1rem, 4vw, 3.1rem);
    font-weight: 400;
    letter-spacing: -0.035em;

    transition: color 180ms ease;
}

.intro-description {
    margin: 0;

    color: var(--text-secondary);

    font-size: 0.96rem;
    line-height: 1.6;

    transition: color 180ms ease;
}


/* ==================================================
   Tool Grid
================================================== */

.tools-grid {
    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(250px, 1fr));

    gap: 18px;

    padding-bottom: 72px;
}


/* ==================================================
   Tool Cards
================================================== */

.tool-card {
    position: relative;
    overflow: hidden;

    min-height: 215px;

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    padding: 28px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 4px;

    color: var(--text-primary);
    text-decoration: none;

    transition:
        background-color 180ms ease,
        color 180ms ease,
        transform 180ms ease,
        border-color 180ms ease,
        box-shadow 180ms ease;
}

.tool-card::after {
    content: "";

    position: absolute;

    left: 28px;
    bottom: 0;

    width: 0;
    height: 3px;

    background: var(--cfe-red);

    transition: width 220ms ease;
}

.tool-card:hover {
    transform: translateY(-2px);

    background: var(--surface-hover);
    border-color: var(--border-hover);

    box-shadow:
        0 8px 24px var(--shadow);
}

.tool-card:hover::after {
    width: 48px;
}


/* ==================================================
   Card Header
================================================== */

.tool-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.tool-icon {
    width: 42px;
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--icon-bg);
    color: var(--icon-text);

    border-radius: 3px;

    font-size: 1rem;
    font-weight: 600;

    transition:
        background 180ms ease,
        color 180ms ease;
}

.arrow {
    color: var(--text-secondary);

    font-size: 1.35rem;
    line-height: 1;

    transition:
        color 180ms ease,
        transform 180ms ease;
}

.tool-card:hover .tool-icon {
    background: var(--cfe-red);
    color: var(--white);
}

.tool-card:hover .arrow {
    color: var(--cfe-red);
    transform: translateX(4px);
}


/* ==================================================
   Card Content
================================================== */

.tool-content {
    margin-top: 44px;
}

.tool-content h2 {
    margin: 0 0 9px;

    color: var(--text-primary);

    font-size: 1.18rem;
    font-weight: 600;
    letter-spacing: -0.015em;

    transition: color 180ms ease;
}

.tool-content p {
    margin: 0;

    color: var(--text-secondary);

    font-size: 0.9rem;
    line-height: 1.55;

    transition: color 180ms ease;
}


/* ==================================================
   Footer
================================================== */

.site-footer {
    background: var(--footer-bg);
    border-top: 1px solid var(--border);

    transition:
        background-color 180ms ease,
        border-color 180ms ease;
}

.footer-content {
    min-height: 66px;

    display: flex;
    align-items: center;
    gap: 10px;

    color: var(--text-secondary);

    font-size: 0.75rem;
    letter-spacing: 0.04em;

    transition: color 180ms ease;
}

.footer-dot {
    width: 3px;
    height: 3px;

    background: var(--cfe-red);
    border-radius: 50%;
}


/* ==================================================
   Accessibility
================================================== */

.tool-card:focus-visible {
    outline: 2px solid var(--cfe-red);
    outline-offset: 3px;
}


/* ==================================================
   Mobile
================================================== */

@media (max-width: 600px) {

    .header-content {
        min-height: 68px;
        gap: 14px;
    }

    .theme-toggle {
        width: 36px;
        height: 36px;

        flex-basis: 36px;
    }

    .brand {
        gap: 14px;
    }

    .brand-mark {
        min-width: 66px;
        height: 38px;
    }

    .brand-divider {
        height: 24px;
    }

    .intro {
        padding: 52px 0 28px;
    }

    .tools-grid {
        grid-template-columns: 1fr;
        padding-bottom: 52px;
    }

    .tool-card {
        min-height: 195px;
        padding: 24px;
    }

    .tool-card::after {
        left: 24px;
    }

    .footer-content {
        flex-wrap: wrap;
    }
}
