@import url('https://fonts.googleapis.com/css2?family=Google+Sans+Flex:opsz,slnt,wdth,wght,GRAD,ROND@6..144,-10..0,25..151,1..1000,0..100,0..100');
@import url('https://fonts.googleapis.com/css?family=Google+Sans+Text:400,500,700');
@import url('https://fonts.googleapis.com/css2?family=Baskervville:ital,wght@0,400..700;1,400..700');
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300..700;1,300..700');

/* ── Global reset ─────────────────────────────────── */

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100dvh;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    font-family: 'Google Sans Flex', 'Google Sans', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Focus-visible ring (accessibility) ───────────── */

:focus-visible {
    outline: 2px solid #1a73e8;
    outline-offset: 2px;
}

/* ── Header ───────────────────────────────────────── */

.header {
    --header-top-height: 50px;
    --header-nav-height: 50px;
    --top-collapse: 0px;
    --top-content-opacity: 1;
    --top-content-scale: 1;
    height: calc(var(--header-top-height) + var(--header-nav-height) - var(--top-collapse));
    background-color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 100;
    overflow: hidden;
    transition: height 0.2s ease;
}

.header.header--nav-only {
    --top-collapse: var(--header-top-height);
    --top-content-opacity: 0;
    --top-content-scale: 0.72;
}

.header.header--narrow-open {
    overflow: visible;
}

.header.header--narrow-open .top {
    z-index: 150;
}

.header .top {
    width: min(1122px, 100%);
    margin: 0;
    padding: 10px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 16px;
    margin-top: calc(var(--top-collapse) * -1);
    transition: margin-top 0.2s ease;
    position: relative;
}

.header .top .action {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex: 1;
}

.header .top .search-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 999px;
    background-color: transparent;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.header .top .search-toggle:hover {
    background-color: #f0f4f9;
}

.header .top .search-toggle__icon {
    width: 20px;
    height: 20px;
    fill: #5f6368;
}

.header .top .feedback-toggle {
    display: inline-flex;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 999px;
    background-color: transparent;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.header .top .feedback-toggle:hover {
    background-color: #f0f4f9;
}

.header .top .feedback-toggle__icon {
    width: 22px;
    height: 22px;
    fill: #5f6368;
}

.header .top .subscribe-toggle {
    display: inline-flex;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 999px;
    background-color: transparent;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.header .top .subscribe-toggle:hover {
    background-color: #f0f4f9;
}

.header .top .subscribe-toggle__icon {
    width: 22px;
    height: 22px;
    fill: #5f6368;
}

.header .top > * {
    opacity: var(--top-content-opacity);
    transform: scale(var(--top-content-scale));
    transform-origin: center top;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.header .top .search {
    flex: 1;
    max-width: 720px;
    position: relative;
}

.header .top .search-box {
    position: relative;
    width: 100%;
    max-width: 720px;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background-color: #f0f4f9;
    border-radius: 28px;
}

.search-box input {
    width: 100%;
    min-width: 0;
    border: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    background-color: transparent;
    margin: 0;
}

.search-box input:focus {
    outline: none;
}

.branding {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    color: #000000;
    user-select: none;
}

.header .top .branding {
    font-size: 36px;
    text-decoration: none;
}

.header .top .search-box input {
    font-family: 'Google Sans Text', sans-serif;
    font-size: 16px;
}

.header .top .search-box .search-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    fill: #5f6368;
}

.header .top .search-box .back-icon {
    outline: none;
    display: none;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    fill: #5f6368;
    cursor: pointer;
}

.header .top .search-box .back-icon:active {
    background-color: rgba(60, 64, 67, 0.08);
}

.header .top .search-narrow-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    margin: 0 -8px 0 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    color: inherit;
}

.header .top .search-narrow-toggle:hover {
    background-color: rgba(60, 64, 67, 0.08);
}

.header .top .search-narrow-toggle__icon {
    width: 24px;
    height: 24px;
    fill: #5f6368;
    transition: transform 0.2s ease;
}

.header .top .search-narrow-toggle[aria-expanded="true"] .search-narrow-toggle__icon {
    transform: rotate(180deg);
}

.search-narrow-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    z-index: 120;
    padding: 16px 20px 20px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(60, 64, 67, 0.18), 0 0 1px rgba(60, 64, 67, 0.12);
    border: 1px solid #e8eaed;
}

.search-narrow-panel__heading {
    margin: 0 0 12px;
    font-family: 'Google Sans Text', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #202124;
}

.search-narrow-panel__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.search-narrow-panel__item + .search-narrow-panel__item {
    margin-top: 4px;
}

.search-narrow-panel__label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    font-family: 'Google Sans Text', sans-serif;
    font-size: 14px;
    color: #3c4043;
    cursor: pointer;
    border-radius: 8px;
}

.search-narrow-panel__label:hover {
    background-color: #f8f9fa;
}

.search-narrow-panel__check {
    width: 18px;
    height: 18px;
    accent-color: #1a73e8;
    flex-shrink: 0;
}

@media (min-width: 1080px) {
    .header .top {
        width: 100%;
    }

    .header .top .action {
        flex: 0 0 auto;
        margin-left: auto;
        transform: none;
        gap: 24px;
    }

    .header .top .search {
        position: absolute;
        left: 50%;
        width: min(720px, calc(100% - 280px));
        max-width: 720px;
        transform: translateX(-50%);
    }

    .header .top .search-box {
        max-width: none;
    }
}

/* ── Navigation ───────────────────────────────────── */

.header .nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 80px;
    min-height: 40px;
    border-bottom: 1px solid #cccccc;
}

.header .nav .nav__link {
    margin: 18px 0 0;
    font-family: 'Google Sans Flex';
    font-size: 16px;
    font-weight: 400;
    font-variation-settings: "ROND" 30;
    color: #606060;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.header .nav .nav__link:hover {
    color: #202020;
}

.header .nav .nav__link.is-active {
    font-weight: 450;
    color: #202020;
    border-bottom-color: #202020;
}

/* ── Main content area ────────────────────────────── */

.main {
    background-color: #ffffff;
}

/* ── Article feed ─────────────────────────────────── */

.article-feed {
    width: min(1122px, calc(100% - 32px));
    margin: 0 auto;
    justify-self: center;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.article-feed .article-list__title {
    font-family: 'Google Sans Flex', sans-serif;
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 16px;
}

.article-feed .article-list__feed {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-gap: 24px;
    column-gap: 24px;
    grid-template-columns: 1fr 1fr 1fr;
    justify-items: center;
}

/* ── Article card ─────────────────────────────────── */

.article-list__item {
    width: 100%;
    max-width: 350px;
    height: 150px;
    padding: 0;
    border: 1px solid #c0c0c0;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background-color: #ffffff;
    transition: background-color 0.2s ease;
}

.article-list__link {
    display: flex;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.article-list__item .text {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 8px 16px;
}

.article-list__item .text .date {
    font-family: 'Google Sans Flex', sans-serif;
    font-size: 14px;
    color: #666666;
}

.article-list__item .text .title {
    font-family: 'Google Sans Flex', sans-serif;
    font-size: 16px;
    font-weight: 400;
}

.article-list__item .image {
    width: 50%;
    height: 100%;
    object-fit: cover;
    flex-shrink: 0;
}

.article-list__item:hover {
    background-color: #f7f7f7;
    border-color: #d0d0d0;
}

.article-list__item:hover .text .title {
    text-decoration: underline;
}

.article-list__item:active {
    background-color: #f0f0f0;
    border-color: #e0e0e0;
}

/* ── Responsive: tablet ───────────────────────────── */

@media (max-width: 900px) {
    body {
        grid-template-rows: auto 1fr;
    }

    .header {
        height: calc(var(--header-top-height) + var(--header-nav-height) - var(--top-collapse));
    }

    .header .top .action {
        /* Ensure action area remains visible since it now contains search */
        display: flex;
    }

    .header .nav {
        gap: 64px;
    }

    .article-feed .article-list__feed {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── Responsive: mobile ───────────────────────────── */

@media (max-width: 640px) {
    .header .top {
        gap: 8px;
    }

    .header .top.search-open {
        min-height: 64px;
    }

    .header .top .branding {
        font-size: 24px;
        flex: 0 0 auto;
    }

    .header .top .action {
        flex: 1;
        gap: 8px;
    }

    .header .top .search-toggle,
    .header .top .subscribe-toggle {
        display: inline-flex;
    }

    .header .top .search {
        display: none;
        position: absolute;
        inset: 0;
        z-index: 10;
        background-color: #fff;
        padding: 8px 16px;
        width: 100%;
        max-width: none;
    }

    .header .top.search-open .search {
        display: flex;
        position: relative;
        inset: auto;
        flex: 1;
        min-width: 0;
        align-items: center;
        align-self: stretch;
        padding: 0 8px 0 0;
        background-color: transparent;
        width: auto;
        z-index: 10;
    }

    .header .top.search-open .search-toggle,
    .header .top.search-open .branding {
        display: none;
    }

    .header .top.search-open .search-box .search-icon {
        display: none;
    }

    .header .top.search-open .search-box .back-icon {
        display: block;
    }

    .header .nav {
        gap: 24px;
        overflow-x: auto;
    }

    .article-feed {
        width: calc(100% - 24px);
    }

    .article-feed .article-list__feed {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .article-list__item {
        max-width: none;
    }
}

/* ── Subscribe overlay ────────────────────────────── */

.subscribe-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.subscribe-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.subscribe-modal {
    width: min(440px, calc(100% - 48px));
    background-color: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    transform: translateY(24px) scale(0.96);
    transition: transform 0.25s ease;
    user-select: none;
    /* Material Web defaults to Roboto; use loaded Google Sans Text inside this dialog */
    --md-ref-typeface-brand: 'Google Sans Text', sans-serif;
    --md-ref-typeface-plain: 'Google Sans Text', sans-serif;
    --md-text-button-label-text-size: 16px;
    --md-filled-button-label-text-size: 16px;
}

.subscribe-overlay.open .subscribe-modal {
    transform: translateY(0) scale(1);
}

.subscribe-modal__title {
    font-family: 'Google Sans Flex', serif;
    font-size: 24px;
    font-weight: 350;
    margin: 0 0 24px;
    text-align: center;
}

.subscribe-modal__title .branding {
    font-size: 26px;
}

.subscribe-modal__subtitle {
    font-family: 'Google Sans Text', sans-serif;
    font-size: 16px;
    font-weight: 350;
    color: #5f6368;
    margin: 0 0 16px;
}

.subscribe-modal__input {
    width: 100%;
    height: 48px;
    --md-outlined-text-field-container-shape: 4px;
    --md-outlined-text-field-top-space: 12px;
    --md-outlined-text-field-bottom-space: 12px;
}

.subscribe-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

.subscribe-modal__actions .icon-button:hover {
    color: #202124 !important;
}

.subscribe-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

.subscribe-modal__actions md-filled-button {
    --md-filled-button-leading-space: 16px;
    --md-filled-button-trailing-space: 16px;
}

.subscribe-step.hidden {
    display: none;
}

.success-icon {
    width: 64px;
    height: 64px;
    background-color: #e6f4ea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.success-icon svg {
    width: 32px;
    height: 32px;
    fill: #1e8e3e;
}

#step-success {
    text-align: center;
}

#step-success .subscribe-modal__actions {
    justify-content: center;
}
