/* StackScope Design System */

/* Accessibility */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--color-primary);
    color: #fff;
    padding: 0.5rem 1rem;
    z-index: 1000;
    font-size: 0.9rem;
}

.skip-link:focus {
    top: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

:root {
    --color-primary: #0f766e;
    --color-primary-light: #14b8a6;
    --color-accent: #f59e0b;
    --color-accent-hover: #d97706;
    --color-bg: #f1f5f9;
    --color-bg-card: #ffffff;
    --color-dark: #0f172a;
    --color-text: #1e293b;
    --color-text-muted: #475569;
    --color-border: #e2e8f0;
    --color-success: #16a34a;
    --color-danger: #dc2626;

    --font-heading: 'Noto Sans Display', system-ui, sans-serif;
    --font-body: 'Figtree', system-ui, sans-serif;
    --font-mono: 'Source Code Pro', 'Menlo', monospace;

    --radius: 4px;
    --radius-lg: 6px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

/* Container */
.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Typography */
h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--color-dark);
    line-height: 1.2;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.25rem; }

.mono { font-family: var(--font-mono); }

a {
    color: var(--color-primary);
    text-decoration: none;
}
a:hover { color: var(--color-primary-light); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg-card);
    color: var(--color-text);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    line-height: 1.4;
}
.btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.btn--primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}
.btn--primary:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary-light);
    color: white;
}
.btn--danger {
    border-color: var(--color-danger);
    color: var(--color-danger);
}
.btn--danger:hover {
    background: var(--color-danger);
    color: white;
}
.btn--sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

/* Header */
.site-header {
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
    padding: 1rem 0;
}

.site-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-family: 'Space Grotesk', var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-dark);
}
.site-logo:hover { color: var(--color-dark); }

.site-logo__icon {
    height: 2.2em;
    width: auto;
    vertical-align: -0.55em;
    margin-right: 0.35rem;
}

.nav-links { display: flex; gap: 1.75rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.nav-link {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
}
.nav-link:hover { color: var(--color-primary); }
.nav-link--subtle { font-size: 0.8rem; }

/* Footer */
.site-footer {
    border-top: 1px solid var(--color-border);
    padding: 2.5rem 0;
    margin-top: 4rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.footer-brand {
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--color-dark);
}

.footer-tagline {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}
.footer-links a { color: var(--color-text-muted); }
.footer-links a:hover { color: var(--color-primary); }

/* Cards */
.card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    overflow-x: auto;
}

.card--highlight {
    border-left: 3px solid var(--color-accent);
}

/* Stats */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

/* Strict 4-column layout for homepage stats with tablet fallback */
.stat-grid--4col {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
}
@media (max-width: 1024px) {
    .stat-grid--4col { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-primary);
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* Score badges */
.score {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius);
}

.score--low { background: #fef3c7; color: #92400e; }
.score--medium { background: #dbeafe; color: #1e40af; }
.score--high { background: #dcfce7; color: #166534; }
.score--danger { background: #fee2e2; color: #991b1b; }

.score-explain {
    margin-top: 0.35rem;
}

/* Tech tags */
.tech-tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius);
    background: var(--color-primary);
    color: white;
    white-space: nowrap;
}

.tech-tag--secondary {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

/* Launch grid */
.launch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* Strict 3-column grid for homepage */
.launch-grid--3col {
    grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 900px) {
    .launch-grid--3col { grid-template-columns: repeat(2, 1fr); }
}


.launch-card {
    display: flex;
    flex-direction: column;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-decoration: none;
    color: inherit;
}
.launch-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 12px rgba(26, 83, 92, 0.08);
    color: inherit;
}

/* Featured launch card — side-by-side on desktop, stacked on mobile */
.launch-card.launch-card--featured {
    flex-direction: row;
    max-width: 100%;
}
.launch-card--featured .launch-card__thumb--featured {
    flex: 0 0 320px;
    height: auto;
    min-height: 200px;
    width: 320px;
}
.launch-card--featured .launch-card__body--featured {
    flex: 1;
}
@media (max-width: 720px) {
    .launch-card.launch-card--featured {
        flex-direction: column;
    }
    .launch-card--featured .launch-card__thumb--featured {
        flex: 0 0 auto;
        width: 100%;
        height: 180px;
        min-height: 0;
    }
}

.launch-card__thumb {
    position: relative;
    width: 100%;
    height: 140px;
    overflow: hidden;
    background: var(--color-dark);
}

.launch-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    opacity: 0.9;
    transition: opacity 0.15s;
}

.launch-card:hover .launch-card__thumb img {
    opacity: 1;
}

.launch-card__score {
    position: absolute;
    top: 0;
    right: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    width: 2.4rem;
    height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
}

.score-sq--good { background: rgba(22, 163, 74, 0.9); color: #fff; }
.score-sq--ok { background: rgba(234, 179, 8, 0.9); color: #000; }
.score-sq--low { background: rgba(220, 38, 38, 0.9); color: #fff; }

.launch-card__body {
    padding: 1rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.launch-card__name {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--color-dark);
    margin-bottom: 0.2rem;
}

.launch-card__tagline {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.launch-card__domain {
    font-size: 0.8rem;
    color: var(--color-primary);
    margin-bottom: 0.6rem;
}

.launch-card__tech {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.6rem;
}

.launch-card__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: auto;
}

/* Sections */
.section {
    padding: 3rem 0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.5rem;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
}

.section-link {
    font-size: 0.85rem;
    font-weight: 500;
    color: #b45309;
}
.section-link:hover { color: var(--color-accent-hover); }

/* Hero (homepage) */
.hero {
    padding: 4rem 0 2rem;
}

.hero__title {
    font-size: 2.5rem;
    max-width: 640px;
    line-height: 1.15;
    margin-bottom: 1rem;
}

.hero__subtitle {
    font-size: 1.125rem;
    color: var(--color-text-muted);
    max-width: 520px;
    margin-bottom: 2rem;
}

/* Search */
.search-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.search-input {
    flex: 1;
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg-card);
    color: var(--color-text);
}

.search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.1);
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

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

.search-clear {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Bar charts */
.bar-bg {
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 4px;
    min-width: 2px;
}

.bar-fill--green { background: var(--color-success); }
.bar-fill--amber { background: #eab308; }
.bar-fill--red { background: var(--color-danger); }

/* Outbound links: nofollow styling */
a[rel*="nofollow"]::after {
    content: " \2197";
    font-size: 0.7em;
    opacity: 0.5;
}

/* Detail page */
.detail-header {
    padding: 2.5rem 0 1.5rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 2rem;
}

.detail-header__layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.detail-header__info {
    flex: 1;
    min-width: 0;
}

.detail-header__screenshot {
    flex-shrink: 0;
    width: 280px;
}

.detail-header__screenshot img {
    width: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

@media (max-width: 640px) {
    .detail-header__layout { flex-direction: column; }
    .detail-header__screenshot { width: 100%; max-width: 320px; }
}

/* Snapshot disclaimer */
.snapshot-disclaimer {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    border-left: 3px solid var(--color-border);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
}

/* Score cards row */
.detail-scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.detail-score-card--primary {
    border-color: var(--color-primary);
    border-width: 2px;
}

.detail-score-card--primary .detail-score-card__value {
    font-size: 2rem;
}

.detail-score-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    text-align: center;
}

.detail-score-card__value {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--color-primary);
    line-height: 1;
}

.detail-score-card__max {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--color-text-muted);
}

.detail-score-card__label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* Two-column layout */
.detail-two-col {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.detail-main { min-width: 0; }
.detail-sidebar { min-width: 0; }

/* Checklist style */
.detail-checklist {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.detail-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.25rem 0;
}

.detail-check__icon {
    width: 1.4em;
    text-align: center;
    flex-shrink: 0;
    font-weight: 600;
}

.detail-check--yes .detail-check__icon { color: var(--color-success); }
.detail-check--no .detail-check__icon { color: var(--color-danger); }


.detail-section {
    margin-bottom: 2rem;
}

.detail-section__title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

/* Data table */
.data-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    text-align: left;
    font-weight: 500;
    color: var(--color-text-muted);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.data-table tr:last-child td { border-bottom: none; }

/* Bot page */
.bot-page code {
    font-family: var(--font-mono);
    background: var(--color-bg);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius);
    font-size: 0.875em;
}

.bot-page pre {
    background: var(--color-dark);
    color: #fafaf9;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    overflow-x: auto;
    margin: 1rem 0;
}

/* Observatory (Admin) */
.obs-nav {
    background: var(--color-dark);
    padding: 0.6rem 0;
    border-bottom: 2px solid var(--color-primary);
}
.obs-nav__title {
    font-family: 'Noto Sans Display', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-primary-light, #14b8a6);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.obs-nav__link {
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color 0.15s;
}
.obs-nav__link:hover, .obs-nav__link--active {
    color: #ffffff;
}
.obs-action-btn {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all 0.15s;
}
.obs-action-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.obs-action-btn--danger:hover {
    border-color: var(--color-danger);
    color: var(--color-danger);
}
.obs-live-dot {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-success, #16a34a);
}
.obs-live-dot__pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-success, #16a34a);
    animation: livePulse 2s infinite;
}
.obs-live-dot--paused .obs-live-dot__pulse {
    background: var(--color-text-muted);
    animation: none;
}
.obs-live-dot--paused {
    color: var(--color-text-muted);
}
@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.5); }
}

/* Responsive — tablet */
@media (max-width: 768px) {
    .section { padding: 2rem 0; }
    .section-header { flex-wrap: wrap; gap: 0.75rem; }
    .nav-links { gap: 1rem; }
    .stat-value { font-size: 1.75rem; }
    .detail-score-card--primary .detail-score-card__value { font-size: 1.75rem; }
}

/* Responsive — mobile */
@media (max-width: 640px) {
    .container { padding: 0 1rem; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    .hero__title { font-size: 1.5rem; }
    .section { padding: 1.5rem 0; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .stat-card { padding: 0.75rem 1rem; }
    .stat-value { font-size: 1.5rem; }
    .stat-label { font-size: 0.7rem; }
    .launch-grid { grid-template-columns: 1fr; }
    .footer-content { flex-direction: column; gap: 1rem; }
    .detail-scores { flex-wrap: wrap; }
    .detail-scores-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-two-col { grid-template-columns: 1fr; }
    .detail-score-card { padding: 0.75rem; }
    .detail-score-card--primary .detail-score-card__value { font-size: 1.5rem; }
    .card { padding: 1rem; }
    .nav-links { gap: 0.75rem; }
    .nav-link { font-size: 0.8rem; }
    .site-logo { font-size: 1.1rem; }
    .site-logo__icon { height: 1.8em; }
    .site-footer { padding: 1.5rem 0; margin-top: 2rem; }
    .data-table th, .data-table td { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
    .search-form { flex-direction: column; }
    .search-input { width: 100% !important; }
    .trends-bar-row { grid-template-columns: 90px 1fr 32px; }
    .trends-bar-label { font-size: 0.7rem !important; }
    .obs-nav .container { flex-wrap: wrap; gap: 0.5rem !important; }
    .obs-nav__link { font-size: 0.75rem; }
    .detail-header__screenshot { width: 100%; max-width: 280px; }
}
