/* Tides of War — portal mobile hardening
 * Loaded after each portal page stylesheet on custom pages.
 */

@media (max-width: 760px) {
    body.tow-page img,
    body.tow-portal img {
        max-width: 100%;
        height: auto;
    }

    body.tow-page .tow-shell,
    body.tow-portal .tow-shell {
        width: min(calc(100% - 24px), var(--tow-site-frame));
    }

    .tow-home-section {
        padding-block: 44px;
    }

    .tow-home-hero {
        min-height: 0;
    }

    .tow-home-hero-inner {
        padding-block: 48px;
    }

    .tow-home-hero h1 {
        max-width: 10ch;
        font-size: clamp(2.7rem, 13vw, 4rem);
        text-wrap: balance;
    }

    .tow-home-hero-copy {
        max-width: 44ch;
        line-height: 1.6;
    }

    .tow-actions {
        align-items: stretch;
    }

    .tow-button {
        min-height: 46px;
    }

    .tow-section-heading-row {
        gap: 12px;
    }

    .tow-theater-body {
        min-height: 0;
    }

    .tow-theater-copy {
        font-size: .88rem;
        line-height: 1.55;
    }

    .tow-community-grid,
    .tow-history-layout {
        min-width: 0;
    }

    .tow-activity-panel,
    .tow-frontline-panel {
        min-width: 0;
    }

    .tow-activity-item {
        min-width: 0;
    }

    .tow-activity-title-line,
    .tow-activity-copy {
        min-width: 0;
    }

    .tow-frontline-card,
    .tow-frontline-card-copy,
    .tow-guide-card {
        min-width: 0;
    }

    .tow-history-stats strong {
        font-size: 1.35rem;
    }

    body.tow-page table,
    body.tow-portal table {
        max-width: 100%;
    }

    body.tow-page pre,
    body.tow-page code,
    body.tow-portal pre,
    body.tow-portal code {
        max-width: 100%;
        overflow-x: auto;
    }
}

@media (max-width: 520px) {
    body.tow-page .tow-shell,
    body.tow-portal .tow-shell {
        width: min(calc(100% - 20px), var(--tow-site-frame));
    }

    .tow-home-section {
        padding-block: 38px;
    }

    .tow-home-hero-inner {
        padding-block: 38px;
    }

    .tow-home-hero h1 {
        max-width: 9ch;
        font-size: clamp(2.5rem, 14vw, 3.35rem);
        line-height: 1;
    }

    .tow-home-hero-motto {
        font-size: 1.25rem;
    }

    .tow-home-hero-copy {
        font-size: .95rem;
    }

    .tow-actions {
        grid-template-columns: 1fr;
    }

    .tow-button {
        width: 100%;
        min-height: 48px;
    }

    .tow-theater-art {
        height: 150px;
    }

    .tow-theater-label {
        font-size: 1.45rem;
    }

    .tow-activity-item {
        grid-template-columns: 32px minmax(0, 1fr);
        gap: 10px;
        padding: 12px;
    }

    .tow-activity-stats {
        gap: 12px;
        flex-wrap: wrap;
    }

    .tow-frontline-card {
        padding: 16px;
    }

    .tow-guide-art {
        margin: 8px -16px -16px;
    }

    /* A horizontal five-era rail is awkward at phone widths. Stack the history
     * into a readable sequence instead of requiring sideways scrolling. */
    .tow-history-timeline {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0;
        padding-top: 0;
        overflow: visible;
    }

    .tow-era {
        min-height: 78px;
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        justify-items: start;
        gap: 2px 12px;
        padding: 13px 0;
        border-bottom: 1px solid rgba(147,161,181,.2);
        text-align: left;
    }

    .tow-era:last-child {
        border-bottom: 0;
    }

    .tow-era-icon {
        grid-row: 1 / span 3;
        margin: 0;
        align-self: center;
    }

    .tow-era strong,
    .tow-era b,
    .tow-era p {
        margin: 0;
    }

    .tow-history-stats {
        margin-top: 24px;
    }

    .tow-history-stats span {
        min-width: 0;
        padding: 13px 8px;
    }
}
