/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-bg: #fafafa;
    --secondary-bg: #ffffff;
    --text-primary: #262626;
    --text-secondary: #8e8e8e;
    --border-color: #dbdbdb;
    --accent-color: #0095f6;
    --safe-top: 0px;
    --safe-bottom: 0px;
}

@supports (top: env(safe-area-inset-top)) {
    :root {
        --safe-top: env(safe-area-inset-top);
        --safe-bottom: env(safe-area-inset-bottom);
    }
}

html {
    background-color: #000000;
}

body {
    font-family: 'Onest', 'Helvetica', 'Helvetica Neue', Arial, sans-serif;
    font-weight: 400;
    background-color: var(--secondary-bg);
    color: var(--text-primary);
    overflow-x: hidden;
}

.app-container {
    min-height: 100vh;
    min-height: calc(var(--app-vh, 1vh) * 100);
    position: relative;
}

/* Brand Mark */
.brand-mark {
    position: fixed;
    top: calc(var(--safe-top) + 20px);
    left: 40px;
    font-size: 13px;
    color: #ffffff;
    font-weight: 400;
    z-index: 300;
    pointer-events: none;
    line-height: 1.2;
}

.brand-mark__title {
    display: block;
}

.brand-mark__byline {
    display: block;
    opacity: 0.8;
}

/* Category Filter */
.category-filter {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: auto;
    max-width: 200px;
    z-index: 100;
    pointer-events: none;
}

.category-list {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 30px, black 100px, black calc(100% - 100px), rgba(0,0,0,0.3) calc(100% - 30px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 30px, black 100px, black calc(100% - 100px), rgba(0,0,0,0.3) calc(100% - 30px), transparent 100%);
}

.category-list::-webkit-scrollbar {
    display: none;
}

.category-list.can-scroll-up.can-scroll-down {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 30px, black 100px, black calc(100% - 100px), rgba(0,0,0,0.3) calc(100% - 30px), transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 30px, black 100px, black calc(100% - 100px), rgba(0,0,0,0.3) calc(100% - 30px), transparent 100%);
}

.category-list.can-scroll-up:not(.can-scroll-down) {
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 30px, black 100px, black 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 30px, black 100px, black 100%);
}

.category-list:not(.can-scroll-up).can-scroll-down {
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black calc(100% - 100px), rgba(0,0,0,0.3) calc(100% - 30px), transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, black calc(100% - 100px), rgba(0,0,0,0.3) calc(100% - 30px), transparent 100%);
}

.category-list:not(.can-scroll-up):not(.can-scroll-down) {
    -webkit-mask-image: none;
    mask-image: none;
}

.category-pill {
    background: rgb(226, 225, 223, 0.9);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 400;
    color: #000;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
    user-select: none;
    width: max-content;
    align-self: flex-end;
    line-height: 1;
    flex-shrink: 0;
    
}

.category-pill:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateX(-4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.category-pill.active {
    background: #000;
    border: #fff solid 1px;
    color: #fff;
}

.category-pill.active:hover {
    background: #000;
    transform: translateX(-4px);
}

.category-toggle {
    display: none;
    border: none;
    cursor: pointer;
    font: inherit;
    background: transparent;
    color: inherit;
}

/* Feed Container */
.feed-container {
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    height: 100vh;
    height: calc(var(--app-vh, 1vh) * 100);
}

/* Post Card Styles */
.post-card {
    position: relative;
    width: 100%;
    height: 100vh;
    height: calc(var(--app-vh, 1vh) * 100);
    display: flex;
    align-items: stretch;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
    opacity: 0;
    animation: fadeIn 0.8s ease forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.post-card figure,
.post-card > div {
    position: relative;
    width: 100%;
    height: 100%;
}

.post-card figure {
    overflow: hidden;
    background-color: #000;
    margin: 0;
}

.post-card.has-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 15%;
    transition: transform 0.3s ease;
}

.post-card.has-image figcaption,
.post-card.no-image > div {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: calc(60px + var(--safe-top)) 40px calc(40px + var(--safe-bottom));
    color: white;
}

.post-card.has-image figcaption {
    position: absolute;
    inset: 0;
            background: linear-gradient(
            to bottom,
            rgba(0, 0, 0, 0.2) 0%,
            rgba(0, 0, 0, 0.2) 40%,
            rgba(0, 0, 0, 0.7) 100%
        );
}

.post-card.no-image {
    background: #000;
}

.post-card.no-image > div {
    height: 100%;
}

.post-card h2 {
    font-size: 9vw;
    font-weight: 400;
    margin-bottom: 12px;
    margin-left: -0.6vw;
    line-height: 1.1;
    letter-spacing: -0.02em;
    max-width: 80vw;
    white-space: pre-line;
}

.post-card p {
    font-size: 18px;
    line-height: 1.6;
    font-weight: 400;
    max-width: 900px;
}

.post-card p .today-intro-meta {
    opacity: 0.8;
}

.post-card a {
    color: white;
    text-decoration: underline;
    font-weight: 400;
    font-size: 18px;
    padding: 0;
    background: transparent;
    border: none;
    transition: all 0.2s ease;
}

.post-card p a {
    display: inline;
    margin-top: 0;
}

.post-card-button {
    display: inline-block;
    margin-top: 12px;
}

.post-card a:hover {
    text-decoration: none;
}


/* Loading Indicator */
.loading-indicator {
    display: none;
    text-align: center;
    padding: 40px 20px;
    color: #ffffff;
    background: #000000;
}

.loading-indicator.active {
    display: block;
}

.toast {
    position: fixed;
    top: calc(var(--safe-top) + 20px);
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #ffffff;
    padding: 12px 18px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    max-width: min(560px, 95vw);
    width: fit-content;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    z-index: 1500;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    font-size: 14px;
    line-height: 1.4;
    pointer-events: auto;
}

.toast.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-8px);
    pointer-events: none;
}

.toast-body {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.toast-action {
    background: #ffffff;
    color: #000000;
    border: none;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex: 0 0 auto;
}

.toast-action:hover {
    opacity: 0.8;;
}

.toast [hidden] {
    display: none !important;
}

.toast.is-loading {
    pointer-events: none;
}

.toast-spinner {
    width: 8px;
    height: 8px;
    border-width: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    flex-shrink: 0;
    align-self: center;
}

.toast.is-loading .toast-spinner {
    display: inline-block;
}

#errorToastMessage {
    flex: 0 1 auto;
    min-width: 0;
    white-space: nowrap;
}

.scroll-sentinel {
    width: 100%;
    height: 1px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

.toast .spinner.toast-spinner {
    width: 12px;
    height: 12px;
    border-width: 1px;
    margin: 0;
    flex-shrink: 0;
    align-self: center;
    position: relative;
    top: -2px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Initial Loading Screen */
.initial-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    color: #ffffff;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.initial-loading.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner-large {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 32px;
}

.initial-loading h2 {
    font-size: 18px;
    margin-bottom: 8px;
    font-weight: 400;
}


/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    animation: bounce 2s infinite;
    opacity: 0.7;
}

.scroll-indicator svg {
    width: 32px;
    height: 32px;
    stroke: white;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    40% {
        transform: translateX(-50%) translateY(-10px);
    }
    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* Responsive Design */
@media (max-width: 1080px) {
    .category-toggle {
        display: inline-flex;
        position: fixed;
        top: calc(var(--safe-top) + 20px);
        right: 12px;
        z-index: 250;
        background: rgba(255, 255, 255, 0.95);
        border-radius: 24px;
        padding: 10px 18px;
        font-size: 14px;
        font-weight: 400;
        line-height: 1;
        color: #000;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        max-width: calc(100vw - 40px);
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .category-toggle.is-active {
        transform: translateY(1px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    }

    .category-toggle:focus-visible {
        outline: 2px solid #000;
        outline-offset: 2px;
    }

    .category-filter {
        display: none;
        right: 0;
        left: auto;
        top: 0;
        bottom: 0;
        max-width: 200px;
        pointer-events: none;
        z-index: 200;
    }
    
    .category-filter.is-visible {
        display: block;
        pointer-events: auto;
    }

    .category-list {
        height: 100%;
        overflow-y: auto;
        padding: calc(64px + var(--safe-top)) 12px calc(20px + var(--safe-bottom));
        gap: 10px;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 30px, black 100px, black calc(100% - 100px), rgba(0,0,0,0.3) calc(100% - 30px), transparent 100%);
        mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 30px, black 100px, black calc(100% - 100px), rgba(0,0,0,0.3) calc(100% - 30px), transparent 100%);
    }

    .post-card p,
    .post-card a {
        font-size: 14px;
    }

    .post-card p {
        max-width: none;
    }

    .post-card h2 {
        font-size: clamp(0px, 12vw, 97px);
        max-width: none;
    }

    .post-card.has-image figcaption,
    .post-card.no-image > div {
        padding: calc(40px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
    }

    .brand-mark {
        left: 16px;
    }


    .toast {
        top: 50%;
        transform: translate(-50%, -50%);
        border-radius: 16px;
        gap: 8px;
        max-width: calc(100vw - 24px);
        width: auto;
        flex-wrap: wrap;
    }

    .toast-body {
        flex: 1 1 auto;
    }

    .toast.hidden {
        transform: translate(-50%, -55%);
    }

    .toast-action {
        width: 100%;
        text-align: center;
    }

    #errorToastMessage {
        flex: 1 1 auto;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .initial-loading h2 {
    font-size: 14px;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
    overflow: hidden;
    scrollbar-width: none;
}

body {
    overflow: hidden;
}

/* Hide global scrollbars */
::-webkit-scrollbar {
    width: 0;
    height: 0;
}
}
