/* ==========================================================================
   Defense Startups: two-sided front page
   Additive to Readers. Loaded as its own stylesheet from default.hbs, so the
   Readers build (gulp + Tailwind) never has to run for these styles.
   ========================================================================== */

/* ---- Nameplate type: set by the Nameplate font, case and size settings ---- */

:root {
    --ds-plate-font: var(--font-heading);
    --ds-plate-weight: 900;
    --ds-plate-track: -0.035em;
    --ds-plate-lh: 0.9;
    --ds-plate-case: none;
    --ds-plate-drop: 0.14;
    --ds-word-scale: 1;
}

.ds-npf-playfair {
    --ds-plate-font: "Playfair Display", var(--font-heading);
}

.ds-npf-dela {
    --ds-plate-font: "Dela Gothic One", var(--font-label);
    --ds-plate-weight: 400;
    --ds-plate-track: -0.02em;
    --ds-plate-lh: 1;
    --ds-plate-drop: 0.2;
}

.ds-npc-lower {
    --ds-plate-case: lowercase;
}

.ds-npc-upper {
    --ds-plate-case: uppercase;
}

.ds-nps-medium {
    --ds-word-scale: 0.74;
}

.ds-nps-small {
    --ds-word-scale: 0.52;
}

/* The same mark wherever the name appears: top bar, footer, classic masthead. */
.ds-brand,
.ds-foot-brand,
[data-masthead] {
    font-family: var(--ds-plate-font);
    font-weight: var(--ds-plate-weight);
    letter-spacing: var(--ds-plate-track);
    text-transform: var(--ds-plate-case);
}

.ds-npf-dela .ds-brand,
.ds-npf-dela .ds-foot-brand {
    font-size: 20px;
}

.ds-npf-dela [data-masthead] {
    line-height: 1;
}

/* The two nameplate words as the brand in the top bar and footer. */
.ds-brand-word + .ds-brand-word {
    margin-left: 0.3em;
}

/* ---- Front page grid ----------------------------------------------------- */

.ds-sides {
    --ds-pad: max(48px, calc((100vw - 1664px) / 2));
    --ds-gap: 40px;
    --ds-top: clamp(22px, 5vh, 52px);
    --ds-one-bg: #0c1a2e;
    --ds-one-fg: #f4f1ea;
    --ds-two-bg: #ebe5d8;
    --ds-two-fg: #121a28;
    --ds-rule: color-mix(in oklab, var(--color-fg) 12%, transparent);
    --ds-word-size: calc(10vw * var(--ds-word-scale));

    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

:root.dark .ds-sides {
    --ds-two-bg: #262420;
    --ds-two-fg: #f4f1ea;
}

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

.ds-side {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---- Door ---------------------------------------------------------------- */

.ds-door {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: calc(100svh - 76px);
    min-height: 560px;
    max-height: 900px;
    padding: var(--ds-pad);
    overflow: hidden;
}

.ds-door:hover {
    opacity: 1;
}

.ds-side--one .ds-door {
    color: var(--ds-one-fg);
    background-color: var(--ds-one-bg);
}

.ds-side--two .ds-door {
    color: var(--ds-two-fg);
    background-color: var(--ds-two-bg);
}

.ds-side .ds-door--photo {
    color: #fff;
    background-color: #111;
}

.ds-door-image {
    position: absolute;
    inset: 0;
    z-index: -2;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.ds-door--photo::after {
    position: absolute;
    inset: 0;
    z-index: -1;
    content: "";
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.14) 40%, rgba(0, 0, 0, 0.74) 100%);
}

.ds-door:hover .ds-door-image {
    transform: scale(1.03);
}

/* ---- Nameplate: one half on each door, meeting at the fold --------------- */

.ds-word {
    position: absolute;
    top: var(--ds-top);
    font-family: var(--ds-plate-font);
    font-size: var(--ds-word-size);
    font-weight: var(--ds-plate-weight);
    line-height: var(--ds-plate-lh);
    letter-spacing: var(--ds-plate-track);
    text-transform: var(--ds-plate-case);
    white-space: nowrap;
}

/* The words are drawn from data-word: they are the nameplate, not page text.
   The page's own text is the h1 (site title) and each side's h2. */
.ds-word::before,
.ds-nameplate-stacked [data-ds-fit]::before {
    content: attr(data-word);
}

.ds-side--one .ds-word {
    right: calc(var(--ds-word-size) * 0.1);
}

.ds-side--two .ds-word {
    left: calc(var(--ds-word-size) * 0.1);
}

.ds-nameplate-stacked {
    display: none;
}

/* ---- Door text ----------------------------------------------------------- */

.ds-door-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 36em;
}

.ds-door-label {
    margin: 0;
    font-family: var(--font-label);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    opacity: 0.68;
}

.ds-door-name {
    margin: 14px 0 0;
    font-family: var(--font-heading);
    font-size: clamp(42px, 5vw, 80px);
    font-weight: 400;
    line-height: 1;
    letter-spacing: -0.015em;
}

.ds-door-name--fallback {
    text-transform: capitalize;
}

.ds-door-desc {
    max-width: 27em;
    margin: 16px 0 0;
    font-size: clamp(19px, 1.55vw, 24px);
    line-height: 1.38;
    text-wrap: pretty;
    opacity: 0.84;
}

.ds-door-enter {
    display: inline-flex;
    gap: 12px;
    align-items: center;
    margin-top: 28px;
    font-family: var(--font-label);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.ds-door-enter::after {
    width: 34px;
    height: 1px;
    content: "";
    background: currentColor;
    transition: width 0.25s ease;
}

.ds-door:hover .ds-door-enter::after {
    width: 58px;
}

/* Photo doors: one plain line saying what the picture is and where it is from. */
.ds-door-credit {
    position: absolute;
    right: var(--ds-pad);
    bottom: 16px;
    max-width: 60%;
    font-family: var(--font-label);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-align: right;
    opacity: 0.78;
}

/* ---- Feed under each door ------------------------------------------------ */

.ds-feed {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 48px var(--ds-gap) 90px var(--ds-pad);
}

.ds-side--two .ds-feed {
    padding: 48px var(--ds-pad) 90px var(--ds-gap);
    border-left: 1px solid var(--ds-rule);
}

.ds-card {
    padding: 26px 0 24px;
    border-bottom: 1px solid var(--ds-rule);
}

.ds-card--lead {
    padding-top: 0;
}

.ds-card-media {
    display: block;
    aspect-ratio: 1.6;
    margin-bottom: 26px;
    overflow: hidden;
    background: color-mix(in oklab, var(--color-fg) 8%, transparent);
    border-radius: 4px;
}

.ds-card-media:hover {
    opacity: 1;
}

.ds-card-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ds-card-media:hover img {
    transform: scale(1.03);
}

.ds-card-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: clamp(24px, 2.15vw, 32px);
    font-weight: 400;
    line-height: 1.13;
    letter-spacing: -0.005em;
    text-wrap: pretty;
}

.ds-card--lead .ds-card-title {
    font-size: clamp(30px, 3.4vw, 50px);
    line-height: 1.06;
}

.ds-card-title a:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 6px;
    opacity: 1;
}

.ds-card-excerpt {
    margin: 16px 0 0;
    font-size: clamp(19px, 1.55vw, 24px);
    line-height: 1.42;
    color: color-mix(in oklab, var(--color-fg) 85%, transparent);
    text-wrap: pretty;
}

.ds-card-meta {
    margin: 14px 0 0;
    font-family: var(--font-label);
    font-size: 11px;
    letter-spacing: 0.16em;
    color: color-mix(in oklab, var(--color-fg) 60%, transparent);
    text-transform: uppercase;
}

.ds-card-meta span:empty {
    display: none;
}

.ds-card-meta span:not(:empty) + span:not(:empty)::before {
    margin: 0 0.7em;
    content: "/";
}

.ds-feed-all {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 16px;
    margin-top: auto;
    font-family: var(--font-label);
    font-size: 12px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    border-bottom: 1px solid color-mix(in oklab, var(--color-fg) 25%, transparent);
}

.ds-card + .ds-feed-all,
.ds-feed > .ds-feed-all {
    padding-top: 34px;
}

/* ---- The row under both sides: stories that carry neither tag ------------ */

.ds-between {
    grid-column: 1 / -1;
    padding: 0 var(--ds-pad) 90px;
}

.ds-between-title {
    display: flex;
    gap: 24px;
    align-items: center;
    padding: 0 0 30px;
    margin: 0;
    font-family: var(--font-label);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.ds-between-title::after {
    flex: 1;
    height: 1px;
    content: "";
    background: color-mix(in oklab, var(--color-fg) 25%, transparent);
}

.ds-between-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 56px;
}

.ds-card--between {
    padding: 0;
    border-bottom: 0;
}

/* ---- Wide screens: doors share one height, statements sit at the fold ---- */

@media (min-width: 900px) {
    .ds-sides {
        grid-template-rows: auto 1fr;
    }

    /* Both doors take the height of the taller one, so the feeds start level. */
    @supports (grid-template-rows: subgrid) {
        .ds-side {
            display: grid;
            grid-template-rows: subgrid;
            grid-row: span 2;
        }
    }

    /* Statement door: the tag's name is the nameplate half above it, so the
       word stands in for the heading and the description is set under it. */
    .ds-door--statement {
        justify-content: flex-start;
        height: auto;
        min-height: clamp(360px, 46svh, 560px);
        max-height: none;
        padding-top: var(--ds-top);
        padding-bottom: 40px;
    }

    .ds-side--one .ds-door--statement {
        align-items: flex-end;
        padding-right: calc(var(--ds-word-size) * 0.1);
        text-align: right;
    }

    .ds-side--two .ds-door--statement {
        align-items: flex-start;
        padding-left: calc(var(--ds-word-size) * 0.1);
    }

    .ds-door--statement .ds-word {
        position: static;
        flex: none;
    }

    .ds-door--statement .ds-door-body {
        flex: 1;
        max-width: none;
    }

    .ds-side--one .ds-door--statement .ds-door-body {
        align-items: flex-end;
    }

    /* Kept for screen readers and for the page without styles. */
    .ds-door--statement .ds-door-name {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .ds-door--statement .ds-door-label {
        margin-top: 18px;
    }

    .ds-door--statement .ds-door-desc {
        max-width: 15em;
        /* Clear of the word's descenders, which hang below its line box. */
        margin-top: calc(var(--ds-word-size) * var(--ds-plate-drop) + 0.12em);
        font-family: var(--font-heading);
        font-size: clamp(23px, 2.3vw, 40px);
        line-height: 1.16;
        letter-spacing: -0.005em;
        text-wrap: balance;
        opacity: 0.94;
    }

    .ds-door--statement .ds-door-enter {
        padding-top: 30px;
        margin-top: auto;
    }

    .ds-side--one .ds-door--statement .ds-door-enter {
        flex-direction: row-reverse;
    }

    .ds-side--one .ds-door--statement .ds-door-credit {
        right: auto;
        left: var(--ds-pad);
        text-align: left;
    }
}

/* ---- Fixes to Readers that this site's content needs --------------------- */

/* Readers centres #main with auto margins inside a column flexbox, which makes
   it shrink-to-fit: one wide image in an article then stretches the whole page
   past the screen. A definite width keeps it in place. */
#main {
    width: 100%;
}

/* The front page runs edge to edge; its inner padding holds the column instead. */
.home-template #main {
    max-width: none;
}

/* "Date / reading time" lines: members-only posts have no reading time for
   signed-out visitors, so the slash is drawn only between two filled parts. */
.ds-meta span:empty {
    display: none;
}

.ds-meta span:not(:empty) + span:not(:empty)::before {
    margin: 0 0.55em;
    content: "/";
}

/* ---- Top bar ------------------------------------------------------------- */

.ds-brand {
    white-space: nowrap;
}

.ds-brand--front {
    display: none;
}

.ds-strapline {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-family: var(--font-label);
    font-size: 11px;
    letter-spacing: 0.18em;
    color: color-mix(in oklab, var(--color-fg) 62%, transparent);
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

/* With the title hidden on the front page, keep the buttons on the right. */
.ds-brand--front ~ nav {
    margin-left: auto;
}

@media (max-width: 760px) {
    .ds-strapline {
        display: none;
    }
}

@media (max-width: 560px) {
    .ds-brand {
        font-size: 22px;
    }

    .ds-npf-dela .ds-brand,
    .ds-npf-dela .ds-foot-brand {
        font-size: 16px;
    }
}

/* ---- Small screens: the doors stack, the nameplate becomes one line ------ */

@media (max-width: 899px) {
    .ds-sides {
        --ds-pad: 24px;
        grid-template-columns: minmax(0, 1fr);
    }

    .ds-word {
        display: none;
    }

    .ds-sides--nameplate .ds-nameplate-stacked {
        display: block;
        padding: 16px var(--ds-pad) 14px;
        margin: 0;
        overflow: hidden;
        font-family: var(--ds-plate-font);
        font-size: 11.4vw;
        font-weight: var(--ds-plate-weight);
        line-height: var(--ds-plate-lh);
        letter-spacing: var(--ds-plate-track);
        text-transform: var(--ds-plate-case);
        white-space: nowrap;
        border-bottom: 1px solid var(--ds-rule);
    }

    .ds-door {
        height: auto;
        min-height: 58svh;
        max-height: none;
        padding-top: 96px;
    }

    /* A statement door with no photo is a band, not a screen of flat colour. */
    .ds-door--statement:not(.ds-door--photo) {
        min-height: 0;
        padding-top: 40px;
        padding-bottom: 30px;
    }

    .ds-door--statement .ds-door-name {
        margin-top: 0;
    }

    .ds-door-credit {
        right: var(--ds-pad);
        bottom: 10px;
    }

    .ds-feed,
    .ds-side--two .ds-feed {
        padding: 36px var(--ds-pad) 56px;
        border-left: 0;
    }

    .ds-between {
        padding-bottom: 56px;
    }

    .ds-between-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .ds-card--between {
        padding: 24px 0;
        border-bottom: 1px solid var(--ds-rule);
    }

    .ds-card--between:first-child {
        padding-top: 0;
    }
}

/* ---- Entrance: the front page is only the two doors ---------------------- */

.ds-sides--entrance {
    min-height: calc(100svh - 76px);
}

.ds-sides--entrance .ds-side {
    display: flex;
    flex-direction: column;
}

.ds-sides--entrance .ds-door {
    flex: 1;
    height: auto;
    max-height: none;
}

@media (min-width: 900px) {
    .ds-sides--entrance {
        grid-template-rows: minmax(0, 1fr);
    }

    .ds-sides--entrance .ds-side {
        display: flex;
        grid-row: auto;
    }

    .ds-sides--entrance .ds-door--statement {
        justify-content: center;
        min-height: calc(100svh - 76px);
        padding-top: var(--ds-pad);
        padding-bottom: var(--ds-pad);
    }

    .ds-sides--entrance .ds-door--statement .ds-door-body {
        flex: none;
    }

    .ds-sides--entrance .ds-door--statement .ds-word {
        margin-bottom: 0.08em;
    }
}

@media (max-width: 899px) {
    .ds-sides--entrance .ds-door,
    .ds-sides--entrance .ds-door--statement:not(.ds-door--photo) {
        justify-content: center;
        min-height: calc(50svh - 60px);
        padding-top: 40px;
        padding-bottom: 40px;
    }
}
