/* ==========================================================================
   Miki Bin — portfolio
   Base sizes follow the original Cargo site: 1rem = 10px.
   ========================================================================== */

:root {
    /* ---- Type ------------------------------------------------------ */
    --font-sans: Inter, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
    --fs-small: 1.4rem;      /* captions, metadata (<small>) */
    --fs-body: 1.6rem;       /* body text on the original pages */
    --fs-h2: 3rem;           /* section statements, nav name */
    --fs-h1: 3.8rem;         /* page and chapter headlines */
    --lh-body: 1.4;
    --lh-h1: 1.2;
    --lh-h2: 1.3;
    --fw-regular: 400;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* ---- Color ----------------------------------------------------- */
    --text: #4f4f4f;                    /* body text */
    --ink: #000;                        /* headings, links */
    --muted: rgba(3, 3, 3, 0.48);       /* <small>; ~3.5:1, below AA for body-size text */
    --surface: #fff;
    --surface-dark: #232323;            /* Involvements band and footer */
    --text-on-dark: #eee;
    --muted-on-dark: #b0b0b0;
    --rule: rgba(127, 127, 127, 0.2);   /* <hr> */
    --hero-overlay: rgba(0, 0, 0, 0.31);/* darkens hero video under white text */
    --accent: #2b70fb;                  /* the one link blue used on the Sonos page */

    /* ---- Spacing --------------------------------------------------- */
    --gutter: 3rem;          /* gap between grid columns */
    --page-pad: 10rem;       /* section padding; 6rem tablet, 2.4rem phone */
    --nav-pad-y: 3rem;
    --nav-pad-x: 4.5rem;
}

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

html {
    font-size: 62.5%;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--surface);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    -webkit-font-smoothing: antialiased;
}

img, video, iframe { max-width: 100%; }
img, video { display: block; height: auto; border: 0; }

a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; }
a:active { opacity: 0.7; }
a.image-link:hover { text-decoration: none; }

b, strong { font-weight: 700; }
i, em { font-style: italic; }

h1 {
    margin: 0;
    font-size: var(--fs-h1);
    font-weight: var(--fw-bold);
    line-height: var(--lh-h1);
    color: var(--ink);
}

h2 {
    margin: 0;
    font-size: var(--fs-h2);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-h2);
    color: var(--ink);
}
h2 a { color: rgba(0, 0, 0, 0.85); }

small {
    display: inline-block;
    font-size: var(--fs-small);
    line-height: 1.5;
    color: var(--muted);
}
small a { color: var(--ink); }

hr {
    display: block;
    height: 1px;
    border: 0;
    background: var(--rule);
}

ul, ol { margin: 0; padding: 0 0 0 1em; }

.section-inner img,
.section-inner video { margin-bottom: 0.5em; }

/* ==========================================================================
   Navigation
   ========================================================================== */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    padding: var(--nav-pad-y) var(--nav-pad-x);
    transition: background-color 0.4s;
}

.navbar a { color: #000; }
.navbar a:hover { text-decoration: none; opacity: 0.6; }

.nav-name {
    font-size: var(--fs-h2);
    font-weight: var(--fw-semibold);
    line-height: var(--lh-h2);
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    column-gap: 4rem;
    font-weight: 700;
}

/* White text over dark hero images, until the page scrolls past the hero */
.navbar-light a { color: #fff; }

.navbar.on-scroll { background: #fff; }
.navbar.on-scroll a { color: #000; }

/* ==========================================================================
   Sections (one per Cargo "page" in the original stack)
   ========================================================================== */

.section {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: var(--page-pad);
}

.section-inner {
    position: relative;
    z-index: 1;
    width: 100%;
}

/* Backdrops: full-bleed image, cycling images, or background video */
.backdrop {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background-size: cover;
    background-position: center;
}

.backdrop-slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 1.5s ease;
}
.backdrop-slide.is-active { opacity: 1; }

.backdrop-overlay {
    position: absolute;
    inset: 0;
}

.backdrop-video iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    /* cover the section at 16:9 whatever its shape */
    width: max(100%, 177.78vh);
    height: max(100%, 56.25vw);
    transform: translate(-50%, -50%);
    border: 0;
    pointer-events: none;
}

/* ==========================================================================
   12-column grid (Cargo's grid-row / grid-col)
   ========================================================================== */

.row {
    display: flex;
    gap: var(--gutter);
}
.row.tight { gap: 0; }

.row > .col { flex: 1 1 0; min-width: 0; }
.row > [class^="col-"] { min-width: 0; }

.col-1  { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 1  + 0  * var(--gutter)); }
.col-2  { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 2  + 1  * var(--gutter)); }
.col-3  { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 3  + 2  * var(--gutter)); }
.col-4  { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 4  + 3  * var(--gutter)); }
.col-5  { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 5  + 4  * var(--gutter)); }
.col-6  { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 6  + 5  * var(--gutter)); }
.col-7  { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 7  + 6  * var(--gutter)); }
.col-8  { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 8  + 7  * var(--gutter)); }
.col-9  { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 9  + 8  * var(--gutter)); }
.col-10 { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 10 + 9  * var(--gutter)); }
.col-11 { flex: 0 0 calc((100% - 11 * var(--gutter)) / 12 * 11 + 10 * var(--gutter)); }
.col-12 { flex: 0 0 100%; }

.row.tight > [class^="col-"] { flex-basis: calc(100% / 12 * var(--span, 1)); }
.row.tight > .col-1 { --span: 1; }  .row.tight > .col-2 { --span: 2; }
.row.tight > .col-3 { --span: 3; }  .row.tight > .col-4 { --span: 4; }
.row.tight > .col-5 { --span: 5; }  .row.tight > .col-6 { --span: 6; }
.row.tight > .col-7 { --span: 7; }  .row.tight > .col-8 { --span: 8; }
.row.tight > .col-9 { --span: 9; }  .row.tight > .col-10 { --span: 10; }
.row.tight > .col-11 { --span: 11; } .row.tight > .col-12 { --span: 12; }

/* ==========================================================================
   Image galleries
   ========================================================================== */

.gallery img,
.gallery video { margin: 0; }

/* Justified rows: each image grows in proportion to its aspect ratio */
.gallery-justify {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
}
.gallery-justify > img,
.gallery-justify > video {
    flex: var(--ar, 1.5) 1 calc(var(--ar, 1.5) * 22rem);
    width: 0;
    min-width: 0;
    object-fit: cover;
}
.gallery-justify::after {
    content: "";
    flex: 999 1 0;
}

.gallery-columns {
    display: grid;
    grid-template-columns: repeat(var(--cols, 2), 1fr);
    gap: 1rem;
    margin: 1rem 0;
    align-items: start;
}
.gallery-columns > img,
.gallery-columns > video { width: 100%; }

/* Slideshow */
.slideshow {
    position: relative;
    margin: 1rem 0;
    overflow: hidden;
}
.slideshow > img,
.slideshow > video {
    width: 100%;
    max-height: 85vh;
    object-fit: contain;
}
.slideshow > img:not(.is-active),
.slideshow > video:not(.is-active) {
    position: absolute;
    inset: 0;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}
.slideshow > img,
.slideshow > video { transition: opacity 0.5s ease; }

.slideshow-arrow {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 2;
    width: 30%;
    border: 0;
    background: none;
    cursor: pointer;
    font: inherit;
    font-size: 3rem;
    color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s;
}
.slideshow:hover .slideshow-arrow { opacity: 1; }
.slideshow-arrow.prev { left: 0; text-align: left; padding-left: 1.5rem; }
.slideshow-arrow.next { right: 0; text-align: right; padding-right: 1.5rem; }

/* ==========================================================================
   Lia case study: floating table of contents
   ========================================================================== */

.toc {
    position: fixed;
    top: 50%;
    right: 2rem;
    z-index: 50;
    transform: translateY(-50%);
    font-size: 1.5rem;
    line-height: 1.6;
    opacity: 0.1;
    transition: opacity 0.4s ease-in-out;
}
.toc:hover { opacity: 1; }
.toc ul { list-style: none; padding: 0; }
.toc a { color: #000; }
.toc a:hover { color: blue; text-decoration: none; }

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 1024px) {
    :root { --page-pad: 6rem; }
}

@media (max-width: 768px) {
    html { font-size: 56%; }
    :root { --page-pad: 2.4rem; --gutter: 2rem; }

    /* Cargo's per-section paddings are tuned for desktop */
    .section { padding: 8rem var(--page-pad) var(--page-pad) !important; }
    .section.has-backdrop { padding-top: 12rem !important; }

    .navbar { padding: 1.6rem 2.4rem; flex-direction: column; gap: 0.4rem; }
    .nav-name { font-size: 2.4rem; }
    .nav-links { justify-content: flex-start; column-gap: 2rem; font-size: 1.5rem; }

    .row { flex-direction: column; }
    .row > * { flex: 1 1 auto !important; width: 100%; }
    .row > :empty { display: none; }

    h1 { font-size: 3rem !important; }
    h2 { font-size: 2.2rem !important; }

    .gallery-columns { grid-template-columns: 1fr 1fr; }
    .toc { display: none; }
}
