/* ============================================
   Design System: iOS-native inspired, minimal
   Flat cards with hairline dividers, high contrast
   ============================================ */

/* -- Theme tokens -- */
:root {
    --screen-bg: #F8F9FA;
    --card-bg: #FFFFFF;
    --secondary-bg: #F5F5F5;
    --text-primary: #000000;
    --text-secondary: #595959;
    --text-tertiary: #8E8E93;
    --border: #E5E5E5;
    --accent-blue: #007AFF;
    --positive: #00C853;
    --negative: #FF3B30;
    --warning: #FFC107;

    --font-stack: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --content-max-width: 720px;
    --site-max-width: 1080px;
}


/* -- Reset & base -- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-stack);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--screen-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* -- Layout -- */
.site-header {
    background-color: var(--card-bg);
    border-bottom: 0.5px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: var(--site-max-width);
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
    text-decoration: none !important;
}

.site-tagline {
    display: none;
    font-size: 12px;
    color: var(--text-tertiary);
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.site-nav::-webkit-scrollbar {
    display: none;
}

.site-nav a {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 200ms;
    white-space: nowrap;
}

.site-nav a:hover {
    color: var(--text-primary);
    text-decoration: none;
}

/* -- Inline nav search -- */
.nav-search {
    display: none;
    align-items: center;
}

.nav-search.is-open {
    display: flex;
}

.nav-search-input {
    width: 200px;
    padding: 6px 12px;
    border: 1.5px solid var(--border);
    border-radius: 100px;
    font-size: 14px;
    font-family: var(--font-stack);
    background-color: var(--secondary-bg);
    color: var(--text-primary);
    outline: none;
    transition: border-color 200ms, background-color 200ms;
}

.nav-search-input::placeholder {
    color: var(--text-tertiary);
}

.nav-search-input:focus {
    border-color: var(--accent-blue);
    background-color: var(--card-bg);
}

/* -- Search toggle icon -- */
.search-toggle {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    transition: color 200ms;
}

.search-toggle:hover {
    color: var(--text-primary);
}

.search-toggle.is-active {
    color: var(--accent-blue);
}

/* -- Search results page -- */
.search-form-page {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.search-input-page {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    font-family: var(--font-stack);
    background-color: var(--card-bg);
    color: var(--text-primary);
    outline: none;
    transition: border-color 200ms;
}

.search-input-page::placeholder {
    color: var(--text-tertiary);
}

.search-input-page:focus {
    border-color: var(--accent-blue);
}

.search-btn-page {
    flex-shrink: 0;
}

.search-result-count {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

.site-main {
    max-width: var(--site-max-width);
    margin: 0 auto;
    padding: 0 16px;
    min-height: calc(100vh - 160px);
}

.site-footer {
    border-top: 0.5px solid var(--border);
    padding: 24px 16px;
    margin-top: 48px;
}

.footer-inner {
    max-width: var(--site-max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-inner p {
    font-size: 12px;
    color: var(--text-tertiary);
}

.footer-nav {
    display: flex;
    gap: 16px;
}

.footer-nav a {
    font-size: 12px;
    color: var(--text-tertiary);
    text-decoration: none;
}

.footer-nav a:hover {
    color: var(--text-primary);
}

/* -- Page sections -- */
.page-section {
    padding: 24px 0;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

/* -- Front Page (WSJ-style homepage) -- */
.front-page {
    padding: 24px 0;
}

.fp-date {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--text-primary);
    margin-bottom: 24px;
}

/* Top area: hero + secondary sidebar */
.fp-top {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    padding-bottom: 24px;
    border-bottom: 0.5px solid var(--border);
    margin-bottom: 24px;
}

/* Hero story */
.fp-hero {
    display: block;
    text-decoration: none;
    color: var(--text-primary);
    transition: opacity 200ms;
}

.fp-hero:hover {
    opacity: 0.8;
    text-decoration: none;
}

.fp-hero img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 16px;
}

.fp-hero-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fp-hero-title {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.fp-hero-excerpt {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Meta row (ticker + price + time) */
.fp-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.fp-meta time {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Secondary stories stack */
.fp-secondary {
    display: flex;
    flex-direction: column;
}

.fp-secondary-item {
    display: block;
    padding: 16px 0;
    border-bottom: 0.5px solid var(--border);
    text-decoration: none;
    color: var(--text-primary);
    transition: opacity 200ms;
}

.fp-secondary-item:first-child {
    padding-top: 0;
}

.fp-secondary-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.fp-secondary-item:hover {
    opacity: 0.7;
    text-decoration: none;
}

.fp-secondary-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    margin: 6px 0 4px;
    color: var(--text-primary);
}

.fp-secondary-excerpt {
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Featured cards row */
.fp-featured {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding-bottom: 24px;
    border-bottom: 0.5px solid var(--border);
    margin-bottom: 24px;
}

.fp-featured-card {
    display: block;
    text-decoration: none;
    color: var(--text-primary);
    transition: opacity 200ms;
}

.fp-featured-card:hover {
    opacity: 0.7;
    text-decoration: none;
}

.fp-featured-card img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 10px;
}

.fp-featured-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fp-featured-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

/* Headlines grid */
.fp-headlines {
    display: grid;
    grid-template-columns: 1fr;
    margin-bottom: 24px;
}

.fp-headline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 0.5px solid var(--border);
    text-decoration: none;
    color: var(--text-primary);
    transition: opacity 200ms;
}

.fp-headline:last-child {
    border-bottom: none;
}

.fp-headline:hover {
    opacity: 0.7;
    text-decoration: none;
}

.fp-headline-title {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

/* -- News list (flat items with hairline dividers) -- */
.news-list {
    display: flex;
    flex-direction: column;
}

.news-item {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 0.5px solid var(--border);
    color: var(--text-primary);
    text-decoration: none;
    transition: opacity 200ms;
}

.news-item:hover {
    text-decoration: none;
    opacity: 0.7;
}

.news-item:last-child {
    border-bottom: none;
}

.news-item-image {
    flex-shrink: 0;
    width: 120px;
}

.news-item-image img {
    width: 120px;
    height: 75px;
    object-fit: cover;
    border-radius: 8px;
}

.news-item-content {
    flex: 1;
    min-width: 0;
}

.news-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.news-item-meta time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.news-item-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.news-item-compact .news-item-title {
    font-size: 14px;
}

.news-item-excerpt {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* -- Ticker & Price -- */
.ticker-link {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: 0.3px;
}

.ticker-link-large {
    font-size: 18px;
}

.ticker-price {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.ticker-price-large {
    font-size: 16px;
}

.price-up {
    color: var(--positive);
}

.price-down {
    color: var(--negative);
}

/* -- Article page -- */
.article-page {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 24px 0;
}

.article-header {
    margin-bottom: 24px;
}

.article-badges {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.article-header h1 {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 8px;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.company-name {
    font-weight: 500;
}

.article-hero-image {
    margin-bottom: 24px;
}

.article-hero-image img {
    width: 100%;
    aspect-ratio: 1.6 / 1;
    object-fit: cover;
    border-radius: 8px;
}

.article-body {
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 32px;
}

.article-body p {
    margin-bottom: 16px;
}

.article-body p:last-child {
    margin-bottom: 0;
}

.article-sources {
    background-color: var(--secondary-bg);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.article-sources h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.article-sources ul {
    list-style: none;
    padding: 0;
}

.article-sources li {
    padding: 6px 0;
    border-bottom: 0.5px solid var(--border);
    font-size: 14px;
}

.article-sources li:last-child {
    border-bottom: none;
}

.article-sources a {
    color: var(--accent-blue);
}

.article-ticker-link {
    margin-bottom: 32px;
}

.related-articles {
    border-top: 0.5px solid var(--border);
    padding-top: 24px;
}

.related-articles h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
}

/* -- Hub page -- */
.hub-header {
    margin-bottom: 16px;
}

.hub-header h1 {
    font-size: 22px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* -- Pagination -- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px 0;
}

.pagination-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent-blue);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 12px;
    background-color: var(--secondary-bg);
    transition: opacity 200ms;
}

.pagination-link:hover {
    opacity: 0.7;
    text-decoration: none;
}

.pagination-info {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* -- Buttons -- */
.btn {
    display: inline-block;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: opacity 200ms;
    cursor: pointer;
    border: none;
}

.btn:hover {
    opacity: 0.7;
    text-decoration: none;
}

.btn:active {
    opacity: 0.6;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: #FFFFFF;
}

.btn-secondary {
    background-color: var(--secondary-bg);
    color: var(--text-primary);
}

/* -- States -- */
.view-all {
    text-align: center;
    padding: 24px 0;
}

.empty-state {
    text-align: center;
    padding: 48px 0;
    color: var(--text-tertiary);
    font-size: 16px;
}

.error-page {
    text-align: center;
    padding: 64px 0;
}

.error-page h1 {
    font-size: 32px;
    margin-bottom: 12px;
}

.error-page p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* -- Animations -- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.news-item {
    animation: fadeIn 400ms ease-in;
}

/* -- Desktop adaptations -- */
@media (min-width: 768px) {
    .header-inner {
        padding: 14px 24px;
    }

    .site-logo {
        font-size: 28px;
    }

    .site-tagline {
        display: inline;
    }

    .site-nav {
        gap: 18px;
    }

    .site-nav a {
        font-size: 14px;
    }

    .nav-search-input {
        width: 240px;
    }

    .site-main {
        padding: 0 24px;
    }

    .article-header h1 {
        font-size: 32px;
    }

    .page-title {
        font-size: 28px;
    }

    .news-item-image {
        width: 160px;
    }

    .news-item-image img {
        width: 160px;
        height: 100px;
    }

    .news-item-title {
        font-size: 18px;
    }

    .news-item-excerpt {
        -webkit-line-clamp: 3;
    }

    /* Front page tablet */
    .fp-hero-title {
        font-size: 28px;
    }

    .fp-secondary-title {
        font-size: 18px;
    }

    .fp-featured {
        grid-template-columns: repeat(2, 1fr);
    }

    .fp-headlines {
        grid-template-columns: repeat(2, 1fr);
        column-gap: 24px;
    }

    .fp-featured-title {
        font-size: 16px;
    }
}

@media (min-width: 1024px) {
    /* Front page desktop: hero + secondary side-by-side */
    .fp-top {
        grid-template-columns: 3fr 2fr;
    }

    .fp-hero-title {
        font-size: 32px;
    }

    .fp-featured {
        grid-template-columns: repeat(4, 1fr);
    }

    .fp-headlines {
        grid-template-columns: repeat(3, 1fr);
        column-gap: 32px;
    }

    .news-item-image {
        width: 200px;
    }

    .news-item-image img {
        width: 200px;
        height: 125px;
    }
}
