/* ============================================================================= 
   Responsive hardening layer
   Loaded after main.css. Keeps the 1920px composition intact and only
   adjusts layouts where the original fixed proportions stop fitting.
   ========================================================================== */

:root {
    --tap-target: 44px;
    --reading-width: 72ch;
}

html {
    scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
    min-width: 320px;
}

:where(h1, h2, h3, .page-head__title, .post__title, .about__title, .ep-page__title) {
    overflow-wrap: anywhere;
    text-wrap: balance;
}

:where(p, li, figcaption, .episode-card__excerpt, .site-footer__tagline) {
    overflow-wrap: anywhere;
}

:where(button, a, input, textarea, select) {
    -webkit-tap-highlight-color: transparent;
}

:where(input, textarea, select) {
    max-width: 100%;
}

:where(iframe, video, embed, object) {
    max-width: 100%;
}

/* Prevent long navigation labels or translated copy from forcing overflow. */
.nav,
.nav__list,
.nav__cta-list,
.site-header__actions,
.hero__actions,
.post__actions,
.about__cta,
.ep-toolbar,
.chips {
    min-width: 0;
}

.nav__link,
.btn__label,
.chip,
.site-footer a {
    overflow-wrap: anywhere;
}

/* Ghost/Koenig cards: preserve their layout without allowing fixed internals to
   widen the article beyond the viewport. */
.gh-content :where(figure, .kg-card) {
    max-width: 100%;
}

.gh-content figure {
    margin-inline: 0;
}

.gh-content :where(.kg-bookmark-card, .kg-callout-card, .kg-file-card, .kg-product-card,
                   .kg-audio-card, .kg-video-card, .kg-toggle-card, .kg-signup-card) {
    min-width: 0;
    overflow: hidden;
}

.kg-bookmark-container,
.kg-file-card-container,
.kg-product-card-container {
    max-width: 100%;
}

.kg-bookmark-content,
.kg-bookmark-thumbnail,
.kg-file-card-contents,
.kg-product-card-title-container {
    min-width: 0;
}

.kg-bookmark-title,
.kg-bookmark-description,
.kg-bookmark-metadata,
.kg-file-card-title,
.kg-file-card-caption,
.kg-product-card-title,
.kg-product-card-description {
    overflow-wrap: anywhere;
}

.kg-header-card,
.kg-signup-card {
    width: 100%;
}

.kg-button-card a,
.kg-product-card-button,
.kg-file-card-button {
    max-width: 100%;
    white-space: normal;
    text-align: center;
}

/* Comfortable intermediate desktop widths. */
@media (max-width: 1560px) {
    :root {
        --gutter: clamp(28px, 4.2vw, 64px);
    }

    .site-header__inner {
        gap: clamp(14px, 1.5vw, 24px);
    }

    .nav__list {
        gap: clamp(18px, 2.8vw, 42px);
    }

    .site-footer__inner {
        grid-template-columns: minmax(0, 1.25fr) repeat(2, minmax(180px, .75fr));
    }
}

@media (max-width: 1280px) {
    :root {
        --gutter: clamp(24px, 3.4vw, 44px);
        --header-h: clamp(78px, 8vw, 104px);
    }

    .brand__img {
        width: clamp(174px, 18vw, 230px);
    }

    .icon-btn {
        width: clamp(46px, 4.8vw, 58px);
        height: clamp(46px, 4.8vw, 58px);
    }

    .hero__lead,
    .post__lead,
    .about__body > p:first-of-type {
        max-width: 42rem;
    }

    .episode-card__body {
        padding-inline: clamp(20px, 2.2vw, 28px);
    }

    .site-footer__inner {
        gap: clamp(28px, 4vw, 44px);
    }
}

/* The existing mobile menu starts here; harden it for short and narrow screens. */
@media (max-width: 1180px) {
    .site-header {
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .site-header__inner {
        justify-content: space-between;
    }

    .nav {
        max-height: 100dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-top: calc(var(--header-h) + max(18px, env(safe-area-inset-top)));
        padding-bottom: max(32px, env(safe-area-inset-bottom));
    }

    .nav__link {
        white-space: normal;
    }

    .nav__cta-list,
    .nav__cta-list li {
        width: 100%;
    }

    .hero {
        align-items: flex-start;
        padding-top: calc(var(--header-h) + clamp(40px, 7vw, 76px));
    }

    .hero__content {
        max-width: min(100%, 760px);
    }

    .episode-card {
        max-width: 880px;
    }

    .site-footer__inner {
        grid-template-columns: minmax(0, 1fr) repeat(2, minmax(170px, .7fr));
    }
}

@media (max-width: 980px) {
    :root {
        --gutter: clamp(22px, 4.8vw, 40px);
    }

    .hero__content {
        max-width: 100%;
    }

    .hero__lead {
        max-width: 36rem;
    }

    .episode-card {
        grid-template-columns: 1fr;
        max-width: 720px;
    }

    .episode-card__media {
        aspect-ratio: 16 / 9;
    }

    .episode-card__body {
        gap: 10px;
    }

    .site-footer__inner {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .site-footer__brand {
        grid-column: 1 / -1;
    }

    .brand--footer {
        max-width: min(320px, 70vw);
    }

    .about__body > ul {
        grid-template-columns: 1fr;
        max-width: 760px;
    }

    .about__cta {
        margin-top: clamp(28px, 5vw, 52px);
    }

    .post__cover {
        max-width: 100%;
    }

    .post__content,
    .page-body .post__content {
        max-width: var(--reading-width);
    }
}

@media (max-width: 760px) {
    :root {
        --gutter: clamp(18px, 5vw, 28px);
        --header-h: 76px;
        --radius: 18px;
    }

    html {
        scroll-padding-top: 88px;
    }

    .site-header__inner {
        gap: 12px;
    }

    .brand__img {
        width: clamp(152px, 42vw, 198px);
    }

    .site-header__actions {
        gap: 10px;
    }

    .icon-btn {
        width: 46px;
        height: 46px;
    }

    .nav {
        padding-inline: var(--gutter);
    }

    .nav__link {
        padding-block: 14px;
        font-size: clamp(18px, 5vw, 21px);
    }

    .hero,
    .about,
    .ep-page,
    .post__head {
        padding-top: calc(var(--header-h) + clamp(28px, 8vw, 44px));
    }

    .hero {
        min-height: auto;
    }

    .wordmark {
        width: min(100%, 620px);
    }

    .hero__lead {
        margin-top: 20px;
        font-size: clamp(16px, 4.5vw, 18px);
        line-height: 1.4;
    }

    .hero__actions {
        gap: 12px;
        margin-top: 24px;
    }

    .btn--primary,
    .btn--ghost {
        min-height: 58px;
        padding: 13px 20px;
        border-radius: 16px;
        font-size: 16px;
    }

    .btn__play {
        width: 34px;
        height: 34px;
    }

    .icon--arrow {
        width: 28px;
        height: 28px;
    }

    .episode-card {
        margin-top: 18px;
        border-radius: 18px;
    }

    .episode-card__body {
        padding: 20px;
    }

    .episode-card__title {
        font-size: clamp(20px, 6vw, 26px);
        line-height: 1.15;
    }

    .episode-card__excerpt {
        font-size: 15px;
        line-height: 1.4;
    }

    .episode-card__meta {
        line-height: 1.45;
    }

    .page-head {
        padding-top: calc(var(--header-h) + clamp(26px, 7vw, 42px));
        padding-bottom: 20px;
    }

    .crumbs {
        gap: 4px 8px;
        font-size: 14px;
    }

    .crumbs [aria-current] {
        flex: 1 1 10rem;
        min-width: 0;
    }

    .page-head__title,
    .about__title,
    .ep-page__title {
        font-size: clamp(34px, 10vw, 48px);
        line-height: 1.08;
    }

    .post__title {
        max-width: 100%;
        font-size: clamp(30px, 8.6vw, 44px);
        line-height: 1.08;
    }

    .post__lead,
    .about__body > p:first-of-type,
    .ep-page__lead {
        font-size: 17px;
        line-height: 1.45;
    }

    .post__meta {
        font-size: 14px;
    }

    .post__tags {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

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

    .post__tags > li {
        flex: 0 0 auto;
    }

    .post__body {
        padding-top: 30px;
    }

    .post__content {
        width: 100%;
        font-size: 16px;
        line-height: 1.65;
    }

    .post__content h2 {
        font-size: clamp(23px, 7vw, 30px);
    }

    .post__content h3 {
        font-size: clamp(20px, 6vw, 25px);
    }

    .post__content pre {
        margin-inline: calc(var(--gutter) * -1);
        padding: 18px var(--gutter);
        border-radius: 0;
        font-size: 14px;
    }

    .post__content table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .post__content th,
    .post__content td {
        padding: 9px 10px;
    }

    .kg-width-wide,
    .kg-width-full {
        width: 100vw;
    }

    .kg-gallery-row {
        flex-direction: column;
    }

    .kg-bookmark-container {
        flex-direction: column;
    }

    .kg-bookmark-thumbnail {
        width: 100%;
        aspect-ratio: 16 / 9;
    }

    .kg-bookmark-thumbnail img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .kg-callout-card,
    .kg-file-card-container,
    .kg-product-card-container,
    .kg-toggle-card {
        padding: 18px;
    }

    .kg-button-card a,
    .kg-product-card-button,
    .kg-file-card-button {
        width: 100%;
    }

    .kg-embed-card iframe,
    .kg-video-card video {
        width: 100%;
        aspect-ratio: 16 / 9;
        height: auto;
    }

    .about__body > ul {
        gap: 18px;
        padding: 20px;
    }

    .about__body > ul > li {
        padding-left: 48px;
        font-size: 16px;
        line-height: 1.4;
    }

    .about__body > ul > li::before {
        width: 34px;
        height: 34px;
    }

    .about__cta {
        gap: 12px;
    }

    .about__banner {
        min-height: 58px;
        padding: 14px 20px;
        border-radius: 16px;
        font-size: 16px;
    }

    .ep-toolbar {
        margin-top: 22px;
    }

    .chip {
        min-height: 42px;
        padding-inline: 16px;
        font-size: 16px;
        border-radius: 16px;
    }

    .ep-search {
        min-height: 52px;
        border-radius: 16px;
    }

    .ep-search__input {
        font-size: 16px;
    }

    .ep-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .ep__title {
        font-size: clamp(20px, 6vw, 24px);
    }

    .site-footer__inner {
        grid-template-columns: 1fr;
        padding-top: 40px;
    }

    .site-footer__brand {
        grid-column: auto;
    }

    .site-footer__nav a,
    .site-footer__contact a {
        display: inline-flex;
        align-items: center;
        min-height: var(--tap-target);
        font-size: 17px;
    }

    .site-footer__bottom p {
        padding-top: 18px;
        padding-bottom: max(18px, env(safe-area-inset-bottom));
        font-size: 14px;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    :root {
        --gutter: 18px;
        --header-h: 68px;
        --radius: 16px;
    }

    .site-header {
        padding-top: max(10px, env(safe-area-inset-top));
    }

    .brand__img {
        width: clamp(136px, 43vw, 170px);
    }

    .icon-btn {
        width: 42px;
        height: 42px;
    }

    .site-header__actions {
        gap: 8px;
    }

    .nav {
        padding-top: calc(var(--header-h) + max(16px, env(safe-area-inset-top)));
    }

    .hero,
    .about,
    .ep-page,
    .post__head {
        padding-top: calc(var(--header-h) + 26px);
    }

    .hero__host {
        width: 100%;
        height: 44%;
        opacity: .14;
    }

    .hero__lead {
        font-size: 16px;
    }

    .btn--primary,
    .btn--ghost {
        min-height: 56px;
        padding-inline: 17px;
        font-size: 15px;
    }

    .episode-card__media {
        aspect-ratio: 16 / 10;
    }

    .episode-card__body,
    .ep__body {
        padding: 18px;
    }

    .badge {
        font-size: 11px;
    }

    .page-head {
        padding-top: calc(var(--header-h) + 24px);
    }

    .page-head__title,
    .about__title,
    .ep-page__title,
    .post__title {
        hyphens: auto;
    }

    .post__content blockquote {
        padding-left: .9em;
    }

    .about__body > ul {
        padding: 18px;
    }

    .about__body > ul > li {
        padding-left: 44px;
    }

    .about__cta .btn--primary,
    .post__actions .btn--ghost {
        width: 100%;
    }

    .post__actions .btn--ghost {
        justify-content: space-between;
    }
}

@media (max-width: 360px) {
    :root {
        --gutter: 14px;
    }

    .brand__img {
        width: 128px;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
    }

    .btn--primary,
    .btn--ghost {
        padding-inline: 14px;
    }

    .episode-card__body,
    .ep__body,
    .about__body > ul {
        padding: 16px;
    }
}

/* Short landscape screens: fit the first screen without shrinking text. */
@media (max-height: 700px) and (min-width: 761px) {
    .hero {
        min-height: 700px;
        padding-top: calc(var(--header-h) + 28px);
        padding-bottom: 36px;
    }

    .hero__lead {
        margin-top: 18px;
    }

    .hero__actions {
        margin-top: 22px;
    }

    .episode-card {
        margin-top: 18px;
    }
}

@media (hover: none) {
    .icon-btn:hover,
    .btn:hover,
    .chip:hover,
    .ep:hover {
        transform: none;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .nav,
    .btn--primary,
    .btn--ghost,
    .episode-card,
    .ep,
    .about__body > ul {
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}
