/*
    Name: Carolina Cherechinsky
    Course: Introduction to Web Design and Computer Principles
    Date: October 29, 2026
    Project: Assignment 06 - Grids & Advanced CSS
    Stylesheet for the /grid/ site "Ranked: Search, SEO & Political News".
    Mobile-first: everything is one column by default, and the
    inner grids open into two or three columns at 900px and up.
*/

/* ===== Design Tokens ===== */

:root {
    --paper: #F6F3EC;
    --paper-dark: #ECE6D8;
    --ink: #1C1B1A;
    --ink-soft: #55504A;
    --blue: #1A4FD6;
    --red: #C8371D;
    --rule: #D6CFC0;
    --display: "Fraunces", Georgia, serif;
    --body: "IBM Plex Sans", Arial, sans-serif;
    --mono: "IBM Plex Mono", "Courier New", monospace;
    --gutter: 16px;
}

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

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

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

body {
    margin: 0;
    font-family: var(--body);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--ink);
    background-color: var(--paper);
}

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

h1 {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

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

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

p {
    margin: 0 0 1em;
}

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

a {
    color: var(--blue);
}

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

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

/* Skip link: hidden until a keyboard user tabs to it */
.skip-link {
    position: absolute;
    left: var(--gutter);
    top: -60px;
    padding: 8px 12px;
    background-color: var(--ink);
    color: var(--paper);
    font-family: var(--mono);
    z-index: 10;
}

.skip-link:focus {
    top: 8px;
}

/* ===== OUTER GRID: whole-page layout =====
   Three columns: flexible margin, content track, flexible margin.
   Every direct child of body sits in the centre track, and the
   rows stack header, nav, main and footer (footer pinned to bottom). */

body {
    display: grid;
    grid-template-columns: var(--gutter) 1fr var(--gutter);
    grid-template-rows: auto auto 1fr auto;
    min-height: 100vh;
}

body > * {
    grid-column: 2;
}

/* The nav and footer bands run edge to edge */
body > nav,
body > footer {
    grid-column: 1 / -1;
}

/* ===== Site Header (Flexbox, single axis) ===== */

body > header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 0;
}

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

.logo {
    width: 56px;
    height: 56px;
}

body > header > a:hover .logo circle {
    stroke: var(--red);
}

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

body > header > p > span {
    display: block;
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

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

body > nav {
    background-color: var(--ink);
    border-bottom: 4px solid var(--red);
}

body > nav > ul {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 24px;
    max-width: calc(1180px + var(--gutter) * 2);
    margin: 0 auto;
    padding: 12px var(--gutter);
    list-style: none;
}

body > nav > ul > li > a {
    font-family: var(--mono);
    font-size: 0.9rem;
    color: var(--paper);
    text-decoration: none;
}

body > nav > ul > li > a:hover,
body > nav > ul > li > a[aria-current="page"] {
    color: var(--paper);
    border-bottom: 3px solid var(--red);
}

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

main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 40px;
    padding: 40px 0 56px;
}

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

/* Article heading block: kicker, headline, standfirst */
article > header {
    border-bottom: 1px solid var(--rule);
    padding-bottom: 24px;
    margin-bottom: 32px;
}

article > header > p:first-child {
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--red);
    margin-bottom: 8px;
}

article > header > p:last-child {
    font-family: var(--display);
    font-size: 1.25rem;
    color: var(--ink-soft);
    margin: 0;
}

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

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

article > section:first-of-type > p:first-of-type::first-letter {
    float: left;
    font-family: var(--display);
    font-size: 3.6em;
    font-weight: 800;
    line-height: 0.85;
    margin: 6px 10px 0 0;
    color: var(--red);
}

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

article > figure > img {
    width: 100%;
    border: 1px solid var(--rule);
    background-color: #FFFFFF;
}

article > figure > figcaption {
    margin-top: 8px;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--ink-soft);
}

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

main > aside {
    align-self: start;
    background-color: var(--paper-dark);
    border-top: 4px solid var(--ink);
    padding: 24px;
}

main > aside > h2:first-child {
    font-size: 1.15rem;
    font-family: var(--mono);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

main > aside > ol,
main > aside > ul {
    margin: 0;
    padding-left: 1.2em;
}

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

main > aside > ol > li:first-child {
    font-weight: 600;
}

/* Key-terms definition list */
main > aside > dl {
    margin: 0;
}

main > aside > dl > dt {
    font-family: var(--display);
    font-weight: 600;
    font-size: 1.1rem;
    padding-top: 12px;
    border-top: 1px solid var(--rule);
}

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

main > aside > dl > dd {
    margin: 2px 0 12px;
    color: var(--ink-soft);
}

/* ===== Explore Cards (landing page) ===== */

.explore > h2 {
    border-bottom: 1px solid var(--rule);
    padding-bottom: 12px;
}

.cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Each card is a vertical flex column so the link sits at the bottom */
.cards > li {
    display: flex;
    flex-direction: column;
    padding: 24px;
    border: 1px solid var(--rule);
    background-color: #FFFFFF;
}

.cards > li > p {
    flex-grow: 1;
    color: var(--ink-soft);
}

.cards > li > a {
    font-family: var(--mono);
    font-size: 0.9rem;
    font-weight: 500;
}

/* The first card is featured */
.cards > li:first-child {
    background-color: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

.cards > li:first-child > p {
    color: var(--rule);
}

.cards > li:first-child > a {
    color: #FFFFFF;
}

.cards > li:first-child > a:hover {
    color: #F2B8AC;
}

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

body > footer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 28px var(--gutter);
    background-color: var(--ink);
    color: var(--rule);
    font-family: var(--mono);
    font-size: 0.8rem;
}

body > footer > p {
    margin: 0;
}

body > footer > p:last-child > a {
    color: #FFFFFF;
}

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

@media (min-width: 600px) {
    :root {
        --gutter: 32px;
    }

    .logo {
        width: 72px;
        height: 72px;
    }

    body > header > p {
        font-size: 2.25rem;
    }

    h1 {
        font-size: 3.2rem;
    }

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

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

/* ===== Desktop (900px and up): inner grids break into columns ===== */

@media (min-width: 900px) {

    /* Landing page: three-column scaffold.
       Article takes two columns, aside takes one,
       explore cards run the full width beneath. */
    .layout-feature {
        grid-template-columns: repeat(3, 1fr);
        column-gap: 48px;
    }

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

    .layout-feature > aside {
        position: sticky;
        top: 24px;
    }

    .layout-feature > .explore {
        grid-column: 1 / -1;
    }

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

    /* Rankings page: two-column scaffold with the key-terms
       sidebar on the left and the article on the right. */
    .layout-sidebar {
        grid-template-columns: 1fr 2.4fr;
        column-gap: 56px;
    }

    .layout-sidebar > aside {
        grid-column: 1;
        grid-row: 1;
        position: sticky;
        top: 24px;
    }

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

    /* Data voids page: the article itself becomes a three-column
       grid, so its first three sections sit side by side. */
    .layout-three > article {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        column-gap: 40px;
    }

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

    .layout-three > article > section:last-of-type {
        max-width: 760px;
    }

    h1 {
        font-size: 4rem;
    }
}

/* ===== Wide screens (1244px and up): cap the content track ===== */

@media (min-width: 1244px) {
    body {
        grid-template-columns: 1fr 1180px 1fr;
    }

    body > footer {
        padding-left: calc((100% - 1180px) / 2);
        padding-right: calc((100% - 1180px) / 2);
    }
}
