/* Each colour is light-dark(light, dark). The appearance selector in the footer picks one
   by setting color-scheme; Auto leaves both, so the system appearance decides. */
:root {
    color-scheme: light dark;
    --text: light-dark(#1d1d1f, #f5f5f7);
    --heading: light-dark(#1d1d1f, #f5f5f7);
    --text-secondary: light-dark(#6e6e73, #a1a1a6);
    --link: light-dark(#0066cc, #2997ff);
    --background: light-dark(#fff, #000);
    --fill-light: light-dark(#f5f5f7, #1d1d1f);
    --gradient-top: light-dark(#d5e4f3, #1d1d1f);
    --separator: light-dark(#d2d2d7, #424245);
    --localnav-background: light-dark(rgba(255, 255, 255, 0.72), rgba(22, 22, 23, 0.72));
    --tabnav-track: light-dark(#e8e8ed, #333336);
    --tabnav-pill: light-dark(#1d1d1f, #f5f5f7);
    --tabnav-pill-text: light-dark(#fff, #1d1d1f);
    --toggle-selected: light-dark(#fff, #6e6e73);
    --button: light-dark(#1d1d1f, #f5f5f7);
    --button-hover: light-dark(#424245, #d2d2d7);
    --button-text: light-dark(#fff, #1d1d1f);
    --content-width: 980px;
    /* The one gap between rows on the landing page, as Apple's product pages space their sections. */
    --row-spacing: 100px;
}

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

:root[data-color-scheme="dark"] {
    color-scheme: dark;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 52px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 17px;
    line-height: 1.47;
    letter-spacing: -0.022em;
    color: var(--text);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
    /* A column at least as tall as the window, so short pages keep the footer at the bottom. */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* The screenshots' shadows reach past the page's side padding on narrow windows, so they're cut at
   the edge of the window rather than letting the page scroll sideways. */
main {
    flex: 1;
    overflow-x: clip;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
h2 {
    color: var(--heading);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-weight: 600;
    margin: 0 0 0.6em;
}

/* Section headings follow Apple's headline-reduced style: 40px, then 32px and 28px on smaller screens. */
h2 {
    font-size: 40px;
    line-height: 1.1;
    letter-spacing: 0;
}

p {
    margin: 0 0 1em;
}

.nowrap {
    white-space: nowrap;
}

.text-center {
    text-align: center;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Local navigation */

.localnav {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--localnav-background);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--separator);
}

.localnav-content {
    position: relative;
    display: flex;
    align-items: center;
    max-width: calc(var(--content-width) + 44px);
    height: 52px;
    margin: 0 auto;
    padding: 0 22px;
}

.localnav-title {
    color: var(--text);
    font-size: 21px;
    font-weight: 600;
    letter-spacing: 0.011em;
    margin-right: auto;
}

.localnav-title:hover {
    text-decoration: none;
}

.localnav-menustate {
    display: none;
}

.localnav-menu {
    display: flex;
    align-self: stretch;
    gap: 24px;
    list-style: none;
    margin: 0 24px 0 0;
    padding: 0;
    font-size: 12px;
    letter-spacing: -0.01em;
}

/* Full height, so the current page's underline sits on the bottom edge of the bar. */
.localnav-menu li {
    position: relative;
    display: flex;
    align-items: center;
}

.localnav-link {
    color: var(--text);
    opacity: 0.88;
}

/* Hover only brings the link to full strength, rather than changing its colour. */
.localnav-link:hover {
    opacity: 1;
    text-decoration: none;
}

/* The current page isn't a link, so it keeps the arrow cursor and doesn't react to hover. */
.localnav-link.current,
.localnav-link.current:hover {
    color: var(--text);
    opacity: 1;
    cursor: default;
}

.localnav-link.current::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: var(--text);
}

.localnav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.localnav-menucta {
    display: none;
    width: 20px;
    height: 20px;
    cursor: pointer;
    position: relative;
}

.localnav-chevron::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 5px;
    width: 8px;
    height: 8px;
    border-right: 1.5px solid var(--text);
    border-bottom: 1.5px solid var(--text);
    transform: rotate(45deg);
    transition: transform 0.25s, top 0.25s;
}

.button {
    display: inline-block;
    color: var(--button-text);
    background: var(--button);
    font-size: 12px;
    line-height: 1.34;
    padding: 4px 11px;
    border-radius: 980px;
    white-space: nowrap;
}

.button:hover {
    background: var(--button-hover);
    text-decoration: none;
}

@media (max-width: 734px) {
    .localnav-content {
        height: 48px;
    }

    .localnav-menucta {
        display: block;
    }

    .localnav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 0;
        margin: 0;
        padding: 8px 16px 16px;
        font-size: 17px;
        background: var(--background);
        border-bottom: 1px solid var(--separator);
    }

    .localnav-menu li {
        padding: 10px 0;
        border-top: 1px solid var(--separator);
    }

    /* In the dropdown, the current page is marked by its full-strength text instead. */
    .localnav-link.current::after {
        content: none;
    }

    .localnav-menu li:first-child {
        border-top: none;
    }

    .localnav-menustate:checked ~ .localnav-menu {
        display: flex;
    }

    .localnav-menustate:checked ~ .localnav-actions .localnav-chevron::before {
        top: 9px;
        transform: rotate(225deg);
    }
}

/* Sections */

/* One gradient behind the whole page, light blue at the top fading into the background. */
.bg-gradient {
    background: linear-gradient(to bottom, var(--gradient-top) -50%, var(--background) 100%);
}

/* In dark mode, the gradient runs the other way, from black to a near-black grey, as on Apple's
   developer site. Its stops differ, so it can't come from light-dark() colours alone. It reaches
   the grey 40% of the way down and holds it, so the black of the Logs screenshot stands out
   against it. */
:root[data-color-scheme="dark"] .bg-gradient {
    background: linear-gradient(to bottom, #000 0%, #141414 40%);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-color-scheme="light"]) .bg-gradient {
        background: linear-gradient(to bottom, #000 0%, #141414 40%);
    }
}

.section {
    padding: 4em 0;
}

.section-content {
    max-width: calc(var(--content-width) + 44px);
    margin: 0 auto;
    padding: 0 22px;
}

.section-hero {
    padding-bottom: 0;
}

.section-hero .section-content {
    max-width: calc(820px + 44px);
}

.headline {
    font-size: 48px;
    line-height: 1.083;
    letter-spacing: -0.003em;
    margin-bottom: 0.4em;
}

.intro {
    font-size: 21px;
    line-height: 1.381;
    letter-spacing: 0.011em;
    margin: 0 auto;
}

.hero-image {
    max-width: calc(var(--content-width) + 44px);
    margin: 2em auto 0;
    padding: 0 22px;
}

.hero-image img {
    display: block;
    width: 100%;
    height: auto;
}

/* The page has its own colour scheme setting, so the hero image and screenshots are swapped in CSS
   rather than with <picture> and prefers-color-scheme, which only follows the system. The hidden
   image is left out of the accessibility tree, so its alt text is read only once. The screenshot
   selectors take two classes to win over the display set by .screenshot and .gallery-item img,
   which come later. */
.hero-image .hero-dark,
.screenshot.screenshot-dark,
.gallery-item .screenshot-dark {
    display: none;
}

:root[data-color-scheme="dark"] .hero-image .hero-light,
:root[data-color-scheme="dark"] .screenshot.screenshot-light,
:root[data-color-scheme="dark"] .gallery-item .screenshot-light {
    display: none;
}

:root[data-color-scheme="dark"] .hero-image .hero-dark,
:root[data-color-scheme="dark"] .screenshot.screenshot-dark,
:root[data-color-scheme="dark"] .gallery-item .screenshot-dark {
    display: block;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-color-scheme="light"]) .hero-image .hero-light,
    :root:not([data-color-scheme="light"]) .screenshot.screenshot-light,
    :root:not([data-color-scheme="light"]) .gallery-item .screenshot-light {
        display: none;
    }

    :root:not([data-color-scheme="light"]) .hero-image .hero-dark,
    :root:not([data-color-scheme="light"]) .screenshot.screenshot-dark,
    :root:not([data-color-scheme="light"]) .gallery-item .screenshot-dark {
        display: block;
    }
}

.section-features {
    padding-top: 0;
    padding-bottom: var(--row-spacing);
}

/* Every row, including the first one under the hero image, is set apart by the same gap. */
.section-features .row {
    margin-top: var(--row-spacing);
}

/* Two columns side by side, each with a heading, text and an optional screenshot. Each column
   shares the row's tracks through a subgrid, so its parts line up with the other column's, and
   the screenshots start at the same height however long the text above them is. */
.row-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 4em;
}

.row-features .column {
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
}

/* Full-width rows keep their text a little narrower than the screenshots under it. */
.row-wide p {
    max-width: calc(var(--content-width) * 10 / 12);
}

/* The window shadow is part of each image, so the screenshots need no border or shadow of their own.
   Each image is wider than its column by the shadow, and pulled out by it on every side, so the
   window itself lines up with the text, and the gaps around it are measured from the window. The
   shadow sizes are in image pixels, and divided by the window width, as percentage margins are
   relative to the column's width. --shown-width is how wide the window appears: the column's width,
   unless a narrower one is set, in which case the window is centred in the column. */
.screenshot {
    --shown-width: 100%;
    display: block;
    width: calc(var(--shown-width) * var(--image-width) / var(--window-width));
    max-width: none;
    height: auto;
    margin-top: calc(2em - var(--shown-width) * var(--shadow-top) / var(--window-width));
    margin-bottom: calc(-1 * var(--shown-width) * var(--shadow-bottom) / var(--window-width));
    margin-left: calc((100% - var(--shown-width)) / 2 - var(--shown-width) * var(--shadow-side) / var(--window-width));
}

/* A sheet, 1544 × 1184 pixels with its shadow, around a 1320 × 960-pixel window. The stack of
   sheets under All in one place is made to the same size, with its sheets in the same area. */
.screenshot-sheet {
    --image-width: 1544;
    --window-width: 1320;
    --shadow-side: 112;
    --shadow-top: 76;
    --shadow-bottom: 148;
}

/* The Reports window, 2168 × 1270 pixels with its shadow. */
.screenshot-reports {
    --image-width: 2168;
    --window-width: 1944;
    --shadow-side: 112;
    --shadow-top: 76;
    --shadow-bottom: 148;
}

/* App-style icons, shown at the size the Apple developer site uses for its product icons. */
.feature-logo {
    display: block;
    width: 64px;
    height: 64px;
    margin-bottom: 1em;
}

/* Gallery */

/* The slides are stacked in one box shaped like the screenshots, and fade between each other.
   Like a single screenshot, the box is pulled out by the windows' shadow, 112 pixels on each side
   and 76 on top of an 1800-pixel window, so the windows line up with the text. Of the 148 pixels
   of shadow below, 83 are kept as the gap above the control, and the rest is pulled back. */
.gallery {
    margin-top: calc(2em - 100% * 76 / 1800);
}

.gallery-items {
    position: relative;
    width: calc(100% * 2024 / 1800);
    margin-left: calc(-100% * 112 / 1800);
    margin-bottom: calc(-100% * (148 - 83) / 1800);
    aspect-ratio: 2024 / 1228;
}

.gallery-item {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.gallery-item.current {
    opacity: 1;
}

.gallery-item img {
    display: block;
    width: 100%;
    height: 100%;
}

/* Segmented control under the slides: a rounded track with a pill behind the current item, which
   slides and resizes to the item you choose. */
/* The screenshots' built-in shadow already leaves room below each window, so the control needs no gap of its own. */
.tabnav-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 0;
}

.tabnav {
    position: relative;
    display: inline-flex;
    max-width: 100%;
    padding: 4px;
    border-radius: 980px;
    background: var(--tabnav-track);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabnav::-webkit-scrollbar {
    display: none;
}

.tabnav-item {
    position: relative;
    z-index: 1;
    flex: none;
    padding: 7px 16px;
    border: none;
    border-radius: 980px;
    background: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: 14px;
    line-height: 1.43;
    letter-spacing: -0.016em;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.3s ease;
}

.tabnav-item:hover {
    color: var(--text);
}

.tabnav-item.current,
.tabnav-item.current:hover {
    color: var(--tabnav-pill-text);
    cursor: default;
}

.tabnav-item:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

.tabnav-indicator {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 0;
    width: 0;
    border-radius: 980px;
    background: var(--tabnav-pill);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Router links */

.router-links {
    background: var(--fill-light);
    padding: 3em 0;
}

.router-content {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2em 1em;
    max-width: calc(var(--content-width) + 44px);
    margin: 0 auto;
    padding: 0 22px;
}

.router-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 216px;
    margin: 0 auto;
    color: var(--text);
    text-align: center;
}

.router-link:hover {
    text-decoration: none;
}

.router-link:hover .more {
    text-decoration: underline;
}

.router-icon {
    width: 50px;
    height: 50px;
    margin: 4px auto 10px;
    fill: none;
    stroke: var(--link);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.router-link strong {
    margin-bottom: 0.4em;
}

.router-description,
.more {
    font-size: 14px;
    line-height: 1.43;
}

.router-description {
    margin-bottom: 0.8em;
}

.more {
    color: var(--link);
}

.more::after {
    content: " \203A";
}

/* Release notes */

.release-notes {
    max-width: calc(820px + 44px);
    margin: 0 auto;
    padding: 3em 22px 4em;
}

.release-notes h1 {
    font-size: 40px;
    line-height: 1.1;
    margin-bottom: 0;
}

.release {
    margin-top: 2em;
    padding-top: 2em;
    border-top: 1px solid var(--separator);
}

.release h2 {
    font-size: 24px;
    line-height: 1.17;
    margin-bottom: 0.2em;
}

.release h3 {
    font-size: 19px;
    line-height: 1.21;
    margin: 1.2em 0 0.4em;
}

.release-date {
    color: var(--text-secondary);
    font-size: 14px;
}

.release ul {
    margin: 0 0 1em;
    padding-left: 1.2em;
}

.release li {
    margin-bottom: 0.5em;
}

/* Footer */

.footer {
    background: var(--fill-light);
    color: var(--text-secondary);
    font-size: 12px;
}

.footer-content {
    max-width: calc(var(--content-width) + 44px);
    margin: 0 auto;
    padding: 0 22px 24px;
}

.footer-content p {
    margin: 0;
}

/* Breadcrumbs and the appearance selector sit above the divider; legal links below it. */
.footer-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    padding: 12px 0;
    border-bottom: 1px solid var(--separator);
}

.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    padding-top: 12px;
}

.footer-content .footer-legal {
    margin-top: 8px;
}

.footer-legal a {
    color: var(--text-secondary);
    text-decoration: underline;
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

.breadcrumbs li {
    display: flex;
    align-items: center;
}

/* A thin chevron between crumbs, drawn with borders. */
.breadcrumbs li + li::before {
    content: "";
    width: 5px;
    height: 5px;
    margin: 0 10px 0 7px;
    border-top: 1px solid currentColor;
    border-right: 1px solid currentColor;
    transform: rotate(45deg);
    opacity: 0.6;
}

.breadcrumbs a {
    color: var(--text-secondary);
}

.breadcrumbs [aria-current="page"] {
    color: var(--text);
}

.footer-links {
    display: flex;
    gap: 0 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.footer-links a {
    color: var(--text-secondary);
}

.color-scheme-toggle {
    display: inline-flex;
    padding: 1px;
    border: 1px solid var(--separator);
    border-radius: 980px;
}

.color-scheme-toggle button {
    padding: 2px 10px;
    border: none;
    border-radius: 980px;
    color: var(--text-secondary);
    background: none;
    font: inherit;
    cursor: pointer;
}

.color-scheme-toggle button:hover {
    color: var(--text);
}

.color-scheme-toggle button[aria-checked="true"] {
    color: var(--text);
    background: var(--toggle-selected);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* Responsive */

@media (max-width: 1068px) {
    :root {
        --row-spacing: 80px;
    }

    .headline {
        font-size: 40px;
        line-height: 1.1;
        letter-spacing: 0;
    }

    h2 {
        font-size: 32px;
        line-height: 1.125;
        letter-spacing: 0.004em;
    }

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

@media (max-width: 734px) {
    :root {
        --row-spacing: 60px;
    }

    h2 {
        font-size: 28px;
        line-height: 1.143;
        letter-spacing: 0.007em;
    }

    .headline {
        font-size: 32px;
        line-height: 1.125;
        letter-spacing: 0.004em;
    }

    .intro {
        font-size: 19px;
        line-height: 1.421;
        letter-spacing: 0.012em;
    }

    .section {
        padding: 3em 0;
    }

    .section-features {
        padding-top: 0;
        padding-bottom: var(--row-spacing);
    }

    /* Stacked in one column, there's nothing to line up with, so each column lays out on its own,
       and the columns are spaced like rows. */
    .row-features {
        display: block;
    }

    .row-features .column {
        display: block;
    }

    .row-features .column + .column {
        margin-top: var(--row-spacing);
    }

    /* A sheet spanning the whole column would be taller than the window once the columns stack, so
       it keeps about the size it has side by side. */
    .row-features .screenshot-sheet {
        --shown-width: min(100%, 480px);
    }

    .footer-bottom {
        flex-direction: column;
    }
}

/* Too narrow for two links side by side, each link becomes a row, with its icon beside its text,
   so the four don't each take a screenful. */
@media (max-width: 480px) {
    .router-content {
        grid-template-columns: 1fr;
        gap: 1.75em;
    }

    .router-link {
        display: grid;
        grid-template-columns: 36px 1fr;
        column-gap: 14px;
        align-items: start;
        justify-items: start;
        max-width: none;
        margin: 0;
        text-align: left;
    }

    .router-icon {
        grid-row: span 3;
        width: 36px;
        height: 36px;
        margin: 2px 0 0;
    }

    .router-link strong {
        margin-bottom: 0.2em;
    }

    .router-description {
        margin-bottom: 0.3em;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .gallery-item,
    .tabnav-item,
    .tabnav-indicator {
        transition: none;
    }
}
