/*
    Student: Nicholas Huertas
    Course: Introduction to Web Design and Computer Principles
    Date: October 29, 2026
    Project: Assignment 06 - Grids & Advanced CSS
    Stylesheet for the /grid/ site "One Mile: The Cross Bronx Expressway".
    Mobile-first: everything stacks in one column. At 1000px the
    outer grid moves the header into a left-hand rail, and each
    page's inner grid opens into two or three columns.
*/

/* ===== Colour and Type Tokens ===== */

:root {
    --asphalt: #1E2126;
    --asphalt-light: #2C3037;
    --sign-green: #00653A;
    --sign-green-dark: #004D2C;
    --caution: #F2B705;
    --route-red: #C0392B;
    --concrete: #EFEDE8;
    --white: #FFFFFF;
    --text: #22252A;
    --muted: #5C6168;
    --rule: #D3D0C8;
    --heading: "Overpass", Arial, sans-serif;
    --reading: "Source Serif 4", Georgia, serif;
    --gutter: 20px;
}

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

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    background-color: var(--concrete);
}

body {
    margin: 0;
    font-family: var(--reading);
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--text);
    background-color: var(--concrete);
}

h1,
h2,
h3 {
    font-family: var(--heading);
    line-height: 1.1;
    margin: 0 0 0.5em;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
}

h2 {
    font-size: 1.5rem;
    font-weight: 800;
}

h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

p {
    margin: 0 0 1em;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: var(--sign-green);
}

a:hover {
    color: var(--route-red);
}

a:focus-visible {
    outline: 3px solid var(--caution);
    outline-offset: 3px;
}

/* ===== OUTER GRID: page layout =====
   Mobile: header, main and footer stack in one column.
   Desktop: the header becomes a fixed-width rail on the left. */

body {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
        "header"
        "main"
        "footer";
    min-height: 100vh;
}

body > header {
    grid-area: header;
}

body > main {
    grid-area: main;
}

body > footer {
    grid-area: footer;
}

/* ===== Header and Navigation (Flexbox, single axis) ===== */

body > header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px 16px;
    padding: 18px var(--gutter);
    background-color: var(--asphalt);
    color: var(--white);
    border-bottom: 6px solid var(--caution);
}

body > header > a {
    flex: 0 0 auto;
    line-height: 0;
}

.logo {
    width: 88px;
    height: auto;
}

body > header > a:hover .logo > rect:first-of-type {
    fill: var(--sign-green-dark);
}

body > header > p {
    margin: 0;
    font-family: var(--heading);
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.1;
}

body > header > p > span {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--caution);
}

body > header > nav {
    flex: 1 1 100%;
}

body > header > nav > ul {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

body > header > nav > ul > li > a {
    display: block;
    padding: 6px 12px;
    font-family: var(--heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--white);
    text-decoration: none;
    border: 2px solid var(--asphalt-light);
    border-radius: 6px;
}

body > header > nav > ul > li > a:hover {
    color: var(--white);
    border-color: var(--caution);
}

body > header > nav > ul > li > a[aria-current="page"] {
    background-color: var(--sign-green);
    border-color: var(--white);
}

/* ===== INNER GRID: mobile-first single column ===== */

main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    padding: 36px var(--gutter) 56px;
    max-width: 1200px;
}

/* ===== Article (styled with combinators, no extra classes) ===== */

article > header {
    margin-bottom: 28px;
}

/* Kicker: a small yellow road-sign label */
article > header > p:first-child {
    display: inline-block;
    margin-bottom: 14px;
    padding: 2px 10px;
    font-family: var(--heading);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--asphalt);
    background-color: var(--caution);
    border-radius: 4px;
}

/* Standfirst */
article > header > p:last-child {
    margin: 0;
    font-size: 1.25rem;
    font-style: italic;
    color: var(--muted);
}

article > section {
    margin-bottom: 28px;
}

/* Section headings get a dashed "lane marking" underline */
article > section > h2 {
    padding-bottom: 10px;
    background-image: repeating-linear-gradient(90deg, var(--caution) 0 28px, transparent 28px 44px);
    background-size: 100% 4px;
    background-repeat: no-repeat;
    background-position: left bottom;
}

/* The first paragraph of the first section is the lede */
article > section:first-of-type > p:first-of-type {
    font-size: 1.25rem;
}

/* Figures */
article > figure {
    margin: 0 0 28px;
}

article > figure > img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--rule);
}

article > figure > figcaption {
    margin-top: 8px;
    font-family: var(--heading);
    font-size: 0.85rem;
    color: var(--muted);
}

/* ===== Asides ===== */

main > aside {
    align-self: start;
    padding: 24px;
    color: var(--white);
    background-color: var(--sign-green);
    border: 4px solid var(--white);
    outline: 2px solid var(--sign-green);
    border-radius: 12px;
}

main > aside > h2:first-child {
    font-size: 1.1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

main > aside > dl {
    margin: 0;
}

main > aside > dl > dt {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.35);
    font-family: var(--heading);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

main > aside > dl > dt:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

main > aside > dl > dd {
    margin: 2px 0 0;
    font-family: var(--heading);
    font-size: 1.6rem;
    font-weight: 800;
}

main > aside > ul {
    margin: 0;
    padding-left: 1.1em;
    font-size: 1rem;
}

main > aside > ul > li {
    margin-bottom: 12px;
}

main > aside > ul > li:last-child {
    margin-bottom: 0;
}

/* ===== Timeline (overview page) ===== */

.timeline > ol {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Each entry is a flex column: the year sits on top of the event */
.timeline > ol > li {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
    background-color: var(--white);
    border-left: 6px solid var(--sign-green);
    border-radius: 0 8px 8px 0;
}

.timeline > ol > li > time {
    font-family: var(--heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--sign-green);
}

/* The first and last entries bookend the story */
.timeline > ol > li:first-child,
.timeline > ol > li:last-child {
    background-color: var(--asphalt);
    color: var(--white);
    border-left-color: var(--caution);
}

.timeline > ol > li:first-child > time,
.timeline > ol > li:last-child > time {
    color: var(--caution);
}

/* ===== Route Comparison (East Tremont page) ===== */

.compare > ul {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.compare > ul > li {
    padding: 22px 24px;
    background-color: var(--white);
    border-top: 8px solid var(--sign-green);
    border-radius: 0 0 8px 8px;
}

/* Moses's route is marked in red, like the route on the map */
.compare > ul > li:first-child {
    border-top-color: var(--route-red);
}

.compare > ul > li > p {
    margin: 0 0 4px;
    font-family: var(--heading);
}

.compare > ul > li > p > strong {
    font-size: 1.6rem;
    font-weight: 800;
}

.compare > ul > li:first-child > p > strong {
    color: var(--route-red);
}

.compare > ul > li:last-child > p > strong {
    color: var(--sign-green);
}

/* ===== Footer (Flexbox, single axis) ===== */

body > footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 28px var(--gutter);
    font-family: var(--heading);
    font-size: 0.85rem;
    color: var(--rule);
    background-color: var(--asphalt);
    border-top: 6px solid var(--caution);
}

body > footer > p {
    margin: 0;
}

body > footer > p:last-child > a {
    color: var(--caution);
    font-weight: 600;
}

/* ===== Tablet (640px and up) ===== */

@media (min-width: 640px) {
    :root {
        --gutter: 36px;
    }

    h1 {
        font-size: 3.2rem;
    }

    .timeline > ol {
        grid-template-columns: repeat(2, 1fr);
    }

    .compare > ul {
        flex-direction: row;
    }

    .compare > ul > li {
        flex: 1 1 0;
    }

    body > footer {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
}

/* ===== Desktop (1000px and up) ===== */

@media (min-width: 1000px) {

    /* Outer grid: header becomes a left rail beside main and footer */
    body {
        grid-template-columns: 280px 1fr;
        grid-template-rows: 1fr auto;
        background-image: linear-gradient(90deg, var(--asphalt) 274px, var(--caution) 274px, var(--caution) 280px, transparent 280px);
        grid-template-areas:
            "header main"
            "header footer";
    }

    body > header {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 20px;
        position: sticky;
        top: 0;
        height: 100vh;
        padding: 32px 34px 32px 28px;
        border-bottom: 0;
        background-color: transparent;
    }

    .logo {
        width: 140px;
    }

    body > header > nav {
        flex: 0 0 auto;
        width: 100%;
    }

    body > header > nav > ul {
        flex-direction: column;
    }

    main {
        column-gap: 48px;
        padding: 56px 56px 72px;
    }

    h1 {
        font-size: 4rem;
    }

    /* Overview: three-column scaffold. Article spans two
       columns, the fact sign takes one, timeline spans all. */
    .layout-overview {
        grid-template-columns: repeat(3, 1fr);
    }

    .layout-overview > article {
        grid-column: span 2;
    }

    .layout-overview > aside {
        position: sticky;
        top: 56px;
    }

    .layout-overview > .timeline {
        grid-column: 1 / -1;
    }

    .timeline > ol {
        grid-template-columns: repeat(3, 1fr);
    }

    /* East Tremont: two columns, article on the left and the
       stacked route comparison on the right. */
    .layout-tremont {
        grid-template-columns: 2fr 1fr;
    }

    .layout-tremont > .compare {
        position: sticky;
        top: 56px;
        align-self: start;
    }

    .compare > ul {
        flex-direction: column;
    }

    /* Legacy: two-column scaffold with a sources sidebar. The
       article is itself a two-column grid so "The cost" and
       "Capping the trench" sit side by side. */
    .layout-legacy {
        grid-template-columns: 3fr 1fr;
    }

    .layout-legacy > article {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        column-gap: 36px;
    }

    .layout-legacy > article > header,
    .layout-legacy > article > figure,
    .layout-legacy > article > section:last-of-type {
        grid-column: 1 / -1;
    }

    .layout-legacy > aside {
        position: sticky;
        top: 56px;
    }
}
