:root {
    color-scheme: light dark;
    --seperator: rgb(from canvastext r g b / 0.15);
    --default-accent: light-dark(color(display-p3 1.0 0.518 0.149 / 1.0), color(display-p3 1.0 0.541 0.188 / 1.0));
    --deluxe-accent: light-dark(color(display-p3 0.510 0.365 0.918 / 1.0), color(display-p3 0.541 0.388 0.973 / 1.0));
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

body > header {
    a {
        color: canvastext;
        text-decoration: none;
    }
    
    a:hover {
        color: canvastext;
        opacity: 0.6;
    }
    
    nav {
        display: flex;
        flex-wrap: wrap;
        column-gap: 24px;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--seperator);
        margin: 0 0 40px;
        
        a.site-title {
            flex-shrink: 0;
            white-space: nowrap;
            font-size: 1.2rem;
            font-weight: 700;
            padding: 12px;
            margin-left: -12px;
            
            .logo img {
                width: 1rem;
                height: auto;
            }
        }
        
        .nav-links {
            display: flex;
            flex-wrap: wrap;
            margin: 0 -12px;
            
            a {
                padding: 12px;
            }
        }
        
        a.feed-link img {
            width: auto;
            height: 0.75rem;
        }
    }
}

main {
    min-height: 60vh;
}

h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.5rem;
    margin: 1.25rem 0;
}

h3 {
    margin: 1rem 0
}

p {
    margin: 1rem 0;
}

h1 + p {
    font-size: 1.5rem;
    font-weight: 300;
}

a {
    color: var(--default-accent);
}

a:hover {
    opacity: 0.92;
}

article {
    margin-bottom: 40px;
}

.tags {
    list-style: none;
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tags li a {
    background: #f0f0f0;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: #555;
    text-decoration: none;
}

.tags li a:hover {
    background: #e0e0e0;
}

.article-card {
    padding: 20px 0;
    border-bottom: 1px solid #eee;
}

.article-card h2 {
    margin: 0 0 8px;
}

.article-card p {
    color: #666;
    margin: 0;
}

body > footer {
    margin-top: 64px;
    padding: 20px 0 0;
    border-top: 1px solid var(--seperator);
    color: #999;
    font-size: 0.85rem;
    
    nav {
        display: flex;
        gap: 8px;
        margin: 0 0 24px;
    }
}

ol, ul {
    margin-bottom: 16px;
    padding-left: 24px;
}

li {
    margin-bottom: 4px;
}

code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
}

pre {
    background: #f5f5f5;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 16px;
}

pre code {
    background: none;
    padding: 0;
}

blockquote {
    background: rgb(from canvastext r g b / 0.05);
    border-radius: 8px;
    padding: 32px;
    
    *:first-child {
        margin-top: 0;
    }
    
    *:last-child {
        margin-bottom: 0;
    }
}

hr {
    border: none;
    height: 1px;
    background-color: var(--seperator);
    margin: 32px 0;
}

/** MARK: Tables */

table {
    border-collapse: collapse;
    margin: 20px 0;
}

table, th, td {
    border: 1px solid var(--seperator);
}

td, th {
    padding: 4px;
}

th {
    font-weight: bold;
}

/** MARK: Pictures */

picture.mac-bezel {
    display: block;
    box-sizing: border-box;
    margin: 24px 0 32px;
    position: relative;

    img {
        background: black;
        height: auto;
        width: 100%;
        transform: scale(0.765) translate(0, -4.4%);
    }
}

picture.mac-bezel::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: light-dark(url("/static/images/light/mac-bezel.png"), url("/static/images/dark/mac-bezel.png"));
    background-size: 100%;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 1;
}


picture.ipad-bezel {
    display: block;
    position: relative;
    margin: 48px 0;
    
    img {
        height: auto;
        max-width: 100%;
        transform: scale(0.91) translateY(1%);
    }
}

picture.ipad-bezel::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: light-dark(url("/static/images/light/ipad-bezel.png"), url("/static/images/dark/ipad-bezel.png"));
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 1;
}

picture.iphone-bezel {
    display: block;
    position: relative;
    max-width: 400px;
    margin: 24px 0;
    
    img {
        border-radius: 5%;
        height: auto;
        max-width: 100%;
        transform: scale(0.92);
    }
}

picture.iphone-bezel::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: light-dark(url("/static/images/light/iphone-bezel.png"), url("/static/images/dark/iphone-bezel.png"));
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 1;
}

/*
 Rounded corners rely on renderedBody (Sources/DenWeb/templates.swift) marking
 screenshot images decoding="sync". Without it Safari paints large, async-decoded
 images in tiles that skip the border-radius clip, leaving random corners square
 until a scroll or click. Masks (SVG or gradient) and drop-shadow filters fail
 the same way; they are not a fix.
 */
picture[class$="screenshot"] {
    img {
        box-shadow: rgb(0, 0, 0, 0.4) 0 0 8px;
        max-width: 100%;
    }
}

picture.mac-screenshot {
    img {
        border-radius: 1.3% / 2.3%;
    }
}


picture.ipad-screenshot {
    img {
        border-radius: 2% / 3%;
    }
}

picture.iphone-screenshot {
    img {
        border-radius: 14% / 6%;
        max-width: 360px;
    }
}


.double-portrait-iphone {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    
    picture {
        flex: 1;
    }
}


.call-to-action {
    margin: 48px 0;
    text-align: center;
    
    img {
        height: auto;
        width: 256px;
    }
}

.logo {
    height: 16px;
    width: auto;
    margin-right: 4px;
}

/* MARK: Blog */

.blog-meta {
    font-size: 0.85rem;
    color: rgb(from canvastext r g b / 0.6);
}

.article-card {
    border-bottom-color: var(--seperator);

    p {
        color: rgb(from canvastext r g b / 0.7);
    }

    .blog-meta {
        margin: 0 0 4px;
    }
}

.blog-article-footer {
    margin-top: 48px;
    padding-top: 16px;
    border-top: 1px solid var(--seperator);
    font-size: 0.85rem;
    color: rgb(from canvastext r g b / 0.6);
}


/* MARK: Homepage */

body.home {
    >main, >footer {
        text-align: center;
    }
    
    >footer nav {
        justify-content: center;
    }
    
    div.feature-grid {
        display: grid;
        /* Automatically wraps and scales columns based on available space */
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 8px;
        margin: 32px 0 0;
        
        >div {
          min-height: 8rem;
          background-color: rgb(from canvastext r g b / 0.05);
          border-radius: 12px;
          display: flex;
          align-items: center;
          justify-content: center;
          padding: 20px;
        }
    }
    
    div.aspects-grid {
        display: grid;
        /* Automatically wraps and scales columns based on available space */
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 8px;
        margin: 32px 0 0;
        
        >div {
          min-height: 10rem;
          background-color: rgb(from canvastext r g b / 0.05);
          border-radius: 12px;
          display: flex;
          flex-flow: column;
          justify-content: center;
          padding: 20px;
          
          h3 {
              margin: 0 0 8px;
          }
          
          p {
              margin: 0;
          }
        }
    }
}

/* Illustrated homepage cells: reserved image space prevents loading shifts.
   Empty image alternatives keep the adjacent copy as the accessible description. */
body.home {
    div.feature-grid, div.aspects-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    }

    .feature-grid > div:has(.home-illustration),
    .aspects-grid > div:has(.home-illustration) {
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding: 24px 24px 28px;
    }

    /* The class sits on the <picture>; the nested <img> fills it. */
    .home-illustration {
        display: block;
        width: 220px;
        max-width: 100%;
        flex: none;
        margin: 0 auto 16px;
    }

    .home-illustration img {
        display: block;
        width: 100%;
        height: auto;
        aspect-ratio: 5 / 3;
    }

    .feature-grid > div > p {
        margin: 0;
        max-width: 32ch;
    }
}
