/* Civic-page layout + components for sub-pages
   (history, demographics, places, news). Loads after city-hub.css.
   Hero, .section, .citations, .quick-facts, .cta, .related are inherited
   from city-hub.css and components.css. */

/* ---- Page wrapper + grid ---- */

.civic-page {
    background: var(--color-bg);
}

.civic-page__layout {
    max-width: var(--width-page);
    margin: 0 auto;
    padding: var(--space-5) var(--space-3);
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--width-sidebar);
    gap: var(--space-5);
    align-items: flex-start;
}

@media (max-width: 1024px) {
    .civic-page__layout {
        grid-template-columns: 1fr;
        gap: var(--space-4);
        padding: var(--space-4) var(--space-2);
    }
}

.civic-page__article {
    max-width: var(--width-article);
    width: 100%;
}

.civic-page__sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    position: sticky;
    top: var(--space-3);
}

@media (max-width: 1024px) {
    .civic-page__sidebar { position: static; }
}

/* Page-meta strip — shows page type + as-of date above hero or below.
   Placed inside hero for now; can also stand alone. */

.page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
    margin: 0 auto;
    max-width: var(--width-page);
    padding: var(--space-2) var(--space-3);
    background: var(--color-fog);
    border-bottom: 1px solid var(--color-rule);
    font-family: var(--font-data);
    font-size: var(--text-xs);
    color: var(--color-fg-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
}

.page-meta__label {
    color: var(--color-sacred-gold);
    font-weight: 500;
}

.page-meta__sep {
    color: var(--color-rule);
}

.page-meta__updated {
    margin-left: auto;
}

@media (max-width: 768px) {
    .page-meta { padding: var(--space-1) var(--space-2); }
    .page-meta__updated { margin-left: 0; }
}

/* ---- Section TOC (sticky sidebar widget) ----
   Anchor-link list of section headings on the current page. */

.section-toc {
    background: var(--color-fog);
    border: 1px solid var(--color-rule);
    border-radius: var(--radius);
    padding: var(--space-3);
}

.section-toc__title {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--color-fg-muted);
    margin: 0 0 var(--space-2);
    padding-bottom: var(--space-1);
    border-bottom: 1px solid var(--color-rule);
}

.section-toc ol {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: toc;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.section-toc li {
    counter-increment: toc;
    margin: 0;
    position: relative;
}

.section-toc a {
    display: flex;
    align-items: baseline;
    gap: var(--space-1);
    padding: 6px var(--space-1);
    font-size: var(--text-sm);
    color: var(--color-fg);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
    line-height: 1.35;
}

.section-toc a::before {
    content: counter(toc, decimal-leading-zero);
    font-family: var(--font-data);
    font-size: var(--text-xs);
    color: var(--color-sacred-gold);
    flex-shrink: 0;
    min-width: 1.75em;
}

.section-toc a:hover {
    background: color-mix(in srgb, var(--color-sacred-gold) 8%, transparent);
    border-left-color: var(--color-sacred-gold);
}

/* History timeline variant — shows era period instead of numbers */
.section-toc--timeline a::before {
    content: attr(data-era);
    color: var(--color-sterling);
    text-transform: none;
    letter-spacing: 0;
    min-width: 5em;
}
.section-toc--timeline a {
    border-left: 2px solid var(--color-rule);
    padding-left: var(--space-2);
    margin-left: var(--space-1);
}
.section-toc--timeline a:hover {
    border-left-color: var(--color-sacred-gold);
}

/* ---- Generic figure grid (richer than .demographics-figures) ----
   Used inline in article body. Flexible 2- or 3-column. */

.figure-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin: var(--space-3) 0;
    padding: var(--space-3);
    background: var(--color-fog);
    border: 1px solid var(--color-rule);
    border-radius: var(--radius);
}

.figure-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.figure-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.figure-grid--featured {
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--color-cosmos) 6%, transparent) 0%, transparent 30%),
        var(--color-fog);
    border-color: color-mix(in srgb, var(--color-sacred-gold) 30%, var(--color-rule));
}

.figure-grid .figure {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: var(--space-1) 0;
}

.figure-grid .figure__label {
    font-size: var(--text-xs);
    color: var(--color-fg-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    font-weight: 500;
}

.figure-grid .figure__value {
    font-family: var(--font-data);
    font-size: var(--text-2xl);
    color: var(--color-fg);
    font-weight: 500;
    line-height: 1.05;
    letter-spacing: -0.01em;
}

.figure-grid .figure--accent .figure__value {
    color: var(--color-sacred-gold);
}

.figure-grid .figure__delta {
    font-family: var(--font-data);
    font-size: var(--text-xs);
    color: var(--color-fg-muted);
    margin-top: 2px;
}
.figure-grid .figure__delta--up   { color: var(--color-success); }
.figure-grid .figure__delta--down { color: var(--color-danger); }

.figure-grid .figure__source {
    font-family: var(--font-data);
    font-size: var(--text-xs);
    color: var(--color-fg-muted);
    font-style: italic;
    margin-top: 2px;
}

@media (max-width: 640px) {
    .figure-grid,
    .figure-grid--3,
    .figure-grid--4 { grid-template-columns: 1fr; }
}

/* ---- Comparison callout (city vs county vs state) ----
   Compact horizontal triple-stat used inside demographics. */

.comparison {
    margin: var(--space-3) 0;
    padding: var(--space-2) var(--space-3);
    border-left: 3px solid var(--color-sacred-gold);
    background: color-mix(in srgb, var(--color-sacred-gold) 5%, var(--color-paper));
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.comparison__label {
    font-family: var(--font-data);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--color-fg-muted);
    margin-bottom: var(--space-1);
}

.comparison__row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
    align-items: baseline;
}

.comparison__cell { display: flex; flex-direction: column; gap: 2px; }

.comparison__entity {
    font-size: var(--text-xs);
    color: var(--color-fg-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.comparison__value {
    font-family: var(--font-data);
    font-size: var(--text-lg);
    color: var(--color-fg);
    font-weight: 500;
}

.comparison__cell--primary .comparison__value {
    color: var(--color-sacred-gold);
    font-size: var(--text-xl);
}

@media (max-width: 480px) {
    .comparison__row { grid-template-columns: 1fr; gap: var(--space-1); }
}

/* ---- Timeline section heading ----
   Used by history.hbs sections. Shows era + year range above the heading. */

.section--era {
    position: relative;
    padding-left: var(--space-4);
    border-left: 2px solid var(--color-rule);
    margin-left: var(--space-1);
}

.section--era::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-sacred-gold);
    border: 2px solid var(--color-paper);
    box-shadow: 0 0 0 2px var(--color-sacred-gold);
}

.section--era .section__era {
    font-family: var(--font-data);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--color-sacred-gold);
    margin-bottom: 2px;
    font-weight: 500;
}

.section--era .section__years {
    font-family: var(--font-data);
    font-size: var(--text-sm);
    color: var(--color-fg-muted);
    margin-bottom: var(--space-1);
}

@media (max-width: 768px) {
    .section--era { padding-left: var(--space-3); }
}

/* ---- Place cards (places-overview) ---- */

.place-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}

@media (max-width: 640px) {
    .place-grid { grid-template-columns: 1fr; }
}

.place-card {
    display: flex;
    flex-direction: column;
    background: var(--color-paper);
    border: 1px solid var(--color-rule);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.place-card:hover {
    border-color: var(--color-sacred-gold);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.place-card__media {
    aspect-ratio: 16 / 10;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--color-cosmos) 92%, var(--color-cipher)) 0%,
        var(--color-cosmos) 100%);
    position: relative;
    overflow: hidden;
}

.place-card__media::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 30%,
            color-mix(in srgb, var(--color-sacred-gold) 12%, transparent) 0%,
            transparent 55%);
}

/* Placeholder seal mark for cards without imagery */
.place-card__media-mark {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 56px;
    height: 56px;
    color: var(--color-sacred-gold);
    opacity: 0.5;
}

.place-card__type {
    position: absolute;
    top: 12px;
    left: 12px;
    font-family: var(--font-data);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    background: color-mix(in srgb, var(--color-cosmos) 70%, transparent);
    color: var(--color-sacred-gold);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--color-sacred-gold) 35%, transparent);
}

.place-card__body {
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    flex: 1;
}

.place-card__name {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    line-height: 1.15;
    color: var(--color-fg);
    margin: 0;
    text-wrap: balance;
}

.place-card__meta {
    font-family: var(--font-data);
    font-size: var(--text-xs);
    color: var(--color-fg-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    display: flex;
    gap: var(--space-1);
    flex-wrap: wrap;
}

.place-card__meta-sep { color: var(--color-rule); }

.place-card__brief {
    font-size: var(--text-sm);
    color: var(--color-fg);
    line-height: 1.5;
    margin: var(--space-1) 0 0;
}

.place-card__link {
    margin-top: auto;
    padding-top: var(--space-2);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    color: var(--color-cipher);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.place-card__link:hover { text-decoration: underline; }
.place-card__link::after {
    content: '→';
    font-family: var(--font-data);
    transition: transform 120ms ease;
}
.place-card__link:hover::after { transform: translateX(2px); }

/* ---- News stream ---- */

.news-stream {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-top: var(--space-3);
}

.news-entry {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-rule);
}
.news-entry:last-child { border-bottom: 0; padding-bottom: 0; }

.news-entry__date {
    font-family: var(--font-data);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--color-fg-muted);
    padding-top: 6px;
    position: relative;
}

.news-entry__date-day {
    display: block;
    font-size: var(--text-2xl);
    color: var(--color-sacred-gold);
    line-height: 1;
    margin-top: 2px;
    letter-spacing: -0.01em;
}

.news-entry__date-year {
    display: block;
    color: var(--color-fg-muted);
    margin-top: 4px;
}

.news-entry__body { min-width: 0; }

.news-entry__category {
    font-family: var(--font-data);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--color-cipher);
    margin-bottom: 4px;
    font-weight: 500;
}

.news-entry__title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    line-height: 1.2;
    margin: 0 0 var(--space-1);
    color: var(--color-fg);
    text-wrap: balance;
}

.news-entry__summary {
    font-size: var(--text-base);
    line-height: var(--leading-base);
    color: var(--color-fg);
    margin: 0;
}
.news-entry__summary p:not(:last-child) { margin-bottom: var(--space-1); }
.news-entry__summary a { color: var(--color-cipher); }

.news-entry__source {
    margin-top: var(--space-2);
    font-family: var(--font-data);
    font-size: var(--text-xs);
    color: var(--color-fg-muted);
}
.news-entry__source a { color: var(--color-fg-muted); text-decoration: underline; }
.news-entry__source a:hover { color: var(--color-cipher); }

@media (max-width: 640px) {
    .news-entry {
        grid-template-columns: 1fr;
        gap: var(--space-1);
    }
    .news-entry__date {
        display: flex;
        align-items: baseline;
        gap: var(--space-1);
        padding-top: 0;
    }
    .news-entry__date-day { font-size: var(--text-xl); margin-top: 0; }
    .news-entry__date-year { display: inline; margin-top: 0; }
}
