/* Subway Map - A Free Design by Bryant Smith (bryantsmith.com)

   This page is a little transit map. The coloured lines are drawn with
   CSS grid tracks, and the stations are round dots built with border-radius.
   Change the four line colours in the :root block below and the whole
   network repaints itself. Section headings point you to the right place. */


/* ---- COLOURS & TYPE: change these four line colours first ---- */

:root {
    --red:   #e2231a;   /* Work line    */
    --blue:  #0b6bcb;   /* Words line   */
    --green: #00953b;   /* Studio line  */
    --amber: #f2a900;   /* Life line    */

    --ink:   #101a2e;   /* dark navy used for signs and text */
    --paper: #f5f3ee;   /* page background */
    --card:  #fcfbf8;   /* map paper */
    --text:  #38414f;   /* body copy */
    --muted: #7a8494;   /* quiet captions */
    --line:  #e3ded2;   /* hairline borders */
}


/* ---- RESET & BODY ---- */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--paper);
    color: var(--text);
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.7;
}

/* ---- PAGE WIDTH: keeps everything on one comfortable column ---- */

.wrap {
    margin: 0 auto;
    max-width: 900px;
    padding: 0 24px;
}

main.wrap {
    padding-top: 56px;
}


/* ---- MASTHEAD: the dark sign at the very top ---- */

#masthead {
    background: var(--ink);
    color: #ffffff;
    padding: 26px 0;
}

.masthead-inner {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 20px 32px;
    justify-content: space-between;
}

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

#masthead h1 {
    color: #ffffff;
    font-size: 30px;
    font-weight: bold;
    letter-spacing: 0.5px;
    line-height: 1.1;
}

.tagline {
    color: #9fb0c9;
    font-size: 11px;
    letter-spacing: 2px;
    margin-top: 6px;
    text-transform: uppercase;
}


/* ---- ROUNDEL: the circular transit logo, drawn with pseudo-elements ---- */

.roundel {
    flex: 0 0 auto;
    height: 58px;
    position: relative;
    width: 58px;
}

.roundel::before {
    /* the red disc */
    background: var(--red);
    border-radius: 50%;
    content: "";
    inset: 0;
    position: absolute;
}

.roundel::after {
    /* the white name bar across it */
    background: #ffffff;
    border-radius: 4px;
    color: var(--red);
    content: "SM";
    font-size: 10px;
    font-weight: bold;
    height: 18px;
    left: -10px;
    letter-spacing: 2px;
    line-height: 18px;
    position: absolute;
    right: -10px;
    text-align: center;
    top: 50%;
    transform: translateY(-50%);
}


/* ---- MENU: the row of text links beside the title ---- */

#menu {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 22px;
}

#menu a,
#menu a:visited {
    border-bottom: 2px solid transparent;
    color: #c3cfe2;
    font-size: 11px;
    letter-spacing: 2px;
    padding-bottom: 3px;
    text-decoration: none;
    text-transform: uppercase;
    transition: color 0.15s ease, border-color 0.15s ease;
}

#menu a:hover,
#menu a:focus-visible {
    border-bottom-color: var(--red);
    color: #ffffff;
}


/* ---- LEAD: the opening paragraph ---- */

.lead {
    color: #46505f;
    font-size: 19px;
    line-height: 1.7;
    margin-bottom: 12px;
    max-width: 68ch;
}


/* ---- SECTION HEADINGS: uppercase signage with a coloured bar ---- */

section {
    margin-top: 60px;
}

h2 {
    color: var(--ink);
    font-size: 14px;
    letter-spacing: 3px;
    text-transform: uppercase;
}

h2::before {
    background: var(--red);
    border-radius: 2px;
    content: "";
    display: inline-block;
    height: 4px;
    margin-right: 12px;
    vertical-align: middle;
    width: 26px;
}

.section-note {
    color: var(--muted);
    font-size: 13px;
    margin-top: 8px;
}


/* ---- MAP: a CSS grid with lines and dots placed on it ---- */

.map-scroll {
    margin-top: 24px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.map {
    --row: 58px;   /* height of one grid row; used to trim line ends */
    background-color: var(--card);
    /* a faint dot grid, like map paper */
    background-image: radial-gradient(#e9e5db 1.3px, transparent 1.3px);
    background-size: 24px 24px;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 12px 28px rgba(16, 26, 46, 0.07);
    display: grid;
    grid-template-columns: repeat(12, minmax(40px, 1fr));
    grid-template-rows: repeat(9, var(--row));
    min-width: 520px;
    padding: 20px 16px;
    position: relative;
}


/* ---- TRACKS: the coloured lines themselves ---- */

.track {
    border-radius: 6px;
    box-shadow: 0 0 0 2px rgba(252, 251, 248, 0.75); /* thin white casing */
    position: relative;
    z-index: 1;
}

.track--h { align-self: center; height: 12px; }

/* vertical lines stop half a row short at each end, so they finish
   exactly on the terminal stations instead of overshooting them */
.track--v {
    justify-self: center;
    margin-block: calc(var(--row) / 2);
    width: 12px;
}

.track--red   { background: var(--red); }
.track--green { background: var(--green); }
.track--amber { background: var(--amber); }

.track--red-main   { grid-column: 3 / 12; grid-row: 2 / 3; }
.track--red-branch { grid-column: 10 / 11; grid-row: 2 / 4; }
.track--blue-main  { grid-column: 5 / 6;  grid-row: 1 / 10; background: var(--blue); }
.track--green-main { grid-column: 2 / 12; grid-row: 5 / 6; }
.track--amber-h    { grid-column: 3 / 12; grid-row: 8 / 9; }
.track--amber-v    { grid-column: 11 / 12; grid-row: 5 / 9; }


/* ---- STATIONS: round dots; each dot takes its colour from --line ---- */

.station {
    align-items: center;
    display: flex;
    justify-content: center;
    place-self: center;   /* centre the dot on its grid cell */
    position: relative;
    text-decoration: none;
    z-index: 2;
}

.on-red   { --line: var(--red); }
.on-blue  { --line: var(--blue); }
.on-green { --line: var(--green); }
.on-amber { --line: var(--amber); }

.dot {
    background: #ffffff;
    border: 5px solid var(--line, var(--ink));
    border-radius: 50%;            /* the circle */
    display: block;
    height: 18px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    width: 18px;
}

/* an interchange is a bigger ring in the sign colour */
.station--interchange .dot {
    border-color: var(--ink);
    height: 28px;
    width: 28px;
}

.station:hover .dot,
.station:focus .dot {
    box-shadow: 0 0 0 4px rgba(16, 26, 46, 0.12);
    transform: scale(1.2);
}

.station:focus-visible .dot {
    box-shadow: 0 0 0 4px rgba(226, 35, 26, 0.35);
}


/* ---- STATION LABELS: absolutely placed around each dot ---- */

.station .label {
    background: rgba(252, 251, 248, 0.92);
    border-radius: 4px;
    color: #2b3440;
    font-size: 11px;
    letter-spacing: 0.2px;
    line-height: 1.25;
    padding: 2px 5px;
    position: absolute;
    transition: color 0.15s ease;
    white-space: nowrap;
}

.station:hover .label { color: var(--line, var(--ink)); }

.station--below .label { left: 50%; top: calc(100% + 6px); transform: translateX(-50%); }
.station--above .label { bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); }
.station--right .label { left: calc(100% + 6px); top: 50%; transform: translateY(-50%); }
.station--left  .label { right: calc(100% + 6px); top: 50%; transform: translateY(-50%); }


/* ---- POSITION HELPERS: place an item on the map grid ---- */

.row-1 { grid-row: 1 / 2; }
.row-2 { grid-row: 2 / 3; }
.row-3 { grid-row: 3 / 4; }
.row-5 { grid-row: 5 / 6; }
.row-8 { grid-row: 8 / 9; }
.row-9 { grid-row: 9 / 10; }

.col-2  { grid-column: 2 / 3; }
.col-3  { grid-column: 3 / 4; }
.col-5  { grid-column: 5 / 6; }
.col-8  { grid-column: 8 / 9; }
.col-10 { grid-column: 10 / 11; }
.col-11 { grid-column: 11 / 12; }

.map-hint {
    color: var(--muted);
    font-size: 12px;
    margin-top: 12px;
}


/* ---- LEGEND: a flex row of line swatches ---- */

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 30px;
    list-style: none;
    margin-top: 22px;
}

.legend-item {
    align-items: center;
    display: flex;
    gap: 10px;
}

.swatch {
    background: var(--swatch, var(--ink));
    border-radius: 5px;
    height: 10px;
    position: relative;
    width: 38px;
}

/* the little round stop sitting on each swatch */
.swatch::after {
    background: #ffffff;
    border: 4px solid var(--swatch, var(--ink));
    border-radius: 50%;
    content: "";
    height: 14px;
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
}

.swatch--red    { --swatch: var(--red); }
.swatch--blue   { --swatch: var(--blue); }
.swatch--green  { --swatch: var(--green); }
.swatch--amber  { --swatch: var(--amber); }
.swatch--interchange { --swatch: var(--ink); background: #c9d2e0; }

.legend-name { color: var(--ink); font-size: 13px; font-weight: bold; }
.legend-desc { color: var(--muted); font-size: 12px; }


/* ---- TICKET: the "how to use" note, with punched side notches ---- */

.ticket {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-top: 22px;
    padding: 30px 34px;
    position: relative;
}

.ticket::before,
.ticket::after {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 50%;
    content: "";
    height: 22px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
}

.ticket::before { left: -12px; }
.ticket::after  { right: -12px; }

.ticket p { margin-bottom: 8px; }

.tips {
    list-style: none;
    margin-top: 18px;
}

.tips li {
    color: #46505f;
    padding-left: 26px;
    position: relative;
    margin-bottom: 12px;
}

/* a small round bullet, like a stop on the line */
.tips li::before {
    background: #ffffff;
    border: 3px solid var(--blue);
    border-radius: 50%;
    content: "";
    height: 10px;
    left: 2px;
    position: absolute;
    top: 0.55em;
    transform: translateY(-50%);
    width: 10px;
}

code {
    background: #eef1f5;
    border-radius: 4px;
    color: #2b3440;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    padding: 1px 5px;
}


/* ---- FOOTER: the required credit line ---- */

#footer {
    background: var(--ink);
    color: #9fb0c9;
    font-size: 11px;
    letter-spacing: 1.5px;
    margin-top: 72px;
    padding: 28px 16px;
    text-align: center;
    text-transform: uppercase;
}

#footer a,
#footer a:visited {
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    color: #ffffff;
    text-decoration: none;
}

#footer a:hover {
    border-bottom-color: var(--red);
}


/* ---- SMALL SCREENS: stack the sign and let the legend become a column ---- */

@media (max-width: 640px) {
    .wrap {
        padding: 0 16px;
    }

    main.wrap {
        padding-top: 36px;
    }

    #masthead {
        padding: 20px 0;
    }

    .masthead-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    #masthead h1 {
        font-size: 23px;
    }

    .lead {
        font-size: 16px;
    }

    .map {
        --row: 50px;
    }

    .station .label {
        font-size: 10px;
    }

    .legend {
        flex-direction: column;
        gap: 12px;
    }

    .ticket {
        padding: 24px 22px;
    }

    .ticket::before,
    .ticket::after {
        display: none;
    }

    section {
        margin-top: 44px;
    }
}
