/*
 * ESS - Public portal styling.
 *
 * The portal reuses the TV theme (tv.css) but, unlike the passive TV boards, it
 * is an interactive page viewed on phones. This file relaxes the fixed-height,
 * overflow-hidden TV shell into a normal scrolling page, scales the typography
 * down for small screens, and styles the light/dark toggle.
 */

/* ---- Behave like a normal, scrollable web page (not a fixed TV viewport) ---- */
html.portal,
html.portal body {
    overflow: auto;
    height: auto;
}

.portal-body {
    height: auto;
    min-height: 100vh;
}

.portal-body .tv-content {
    overflow: visible;
}

/* The wall clock is meaningless on a personal device. */
.portal-body .tv-clock {
    display: none;
}

/* ---- Light/dark toggle button ---- */
.tv-theme-toggle {
    position: fixed;
    top: 1.2vh;
    right: 2.2vw;
    z-index: 50;
    display: inline-flex;
    align-items: center;
    gap: 0.5vw;
    padding: 0.7vh 1.1vw;
    font-size: calc(1.8 * var(--fs));
    font-weight: 700;
    border-radius: 999px;
    border: 1px solid var(--tv-card-border);
    background: var(--tv-card-bg);
    color: var(--tv-text);
    cursor: pointer;
    box-shadow: 0 0.4vh 1vh var(--tv-shadow);
}

.tv-theme-toggle:hover {
    border-color: var(--tv-accent);
}

.tv-theme-toggle .ico {
    font-size: calc(2 * var(--fs));
    line-height: 1;
}

/* ---- Wide tables scroll horizontally instead of overflowing the screen ---- */
.tv-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tv-table-wrap .tv-table {
    min-width: 640px;
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
    .portal-body .tv-header {
        padding: 12px 14px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .portal-body .tv-header .tv-brand img { height: 30px; }
    .portal-body .tv-back { font-size: 14px; padding: 8px 10px; gap: 6px; border-radius: 8px; }
    .portal-body .tv-match-name { font-size: 18px; white-space: normal; }
    .portal-body .tv-screen-sub { font-size: 12px; }

    .portal-body .tv-content { padding: 14px; }
    .portal-body .tv-screen-title { font-size: 22px; }
    .portal-body .tv-section-title { font-size: 18px; }
    .portal-body .tv-section-sub { font-size: 14px; }
    .portal-body .tv-empty-screen { font-size: 20px; }

    /* Link/result cards stack into a single column. */
    .portal-body .tv-cards { grid-template-columns: 1fr; gap: 10px; }
    .portal-body .tv-link-card { padding: 14px; }
    .portal-body .tv-link-title { font-size: 18px; }
    .portal-body .tv-link-desc { font-size: 13px; }

    /* Search box and buttons. */
    .portal-body .tv-search { max-width: 100%; gap: 8px; margin: 14px 0; }
    .portal-body .tv-search input[type="text"] { font-size: 16px; padding: 10px 12px; border-radius: 8px; }
    .portal-body .tv-btn { font-size: 14px; padding: 10px 12px; }
    .portal-body .tv-search .tv-btn { font-size: 16px; }

    /* Shooter detail. */
    .portal-body .tv-detail-name { font-size: 20px; }
    .portal-body .tv-detail-meta { font-size: 14px; gap: 10px; }

    /* Grouping tabs align left and wrap. */
    .portal-body .tv-toolbar { justify-content: flex-start; }

    /* Tables: smaller type; the wrapper handles horizontal scroll. */
    .portal-body .tv-table thead th { font-size: 11px; padding: 8px; }
    .portal-body .tv-table tbody td { font-size: 13px; padding: 7px 8px; }
    .portal-body .tv-table .place { width: auto; }

    /* Toggle: icon only, fixed pixel sizing. */
    .tv-theme-toggle {
        top: 10px;
        right: 12px;
        padding: 8px 12px;
        font-size: 13px;
        gap: 6px;
    }
    .tv-theme-toggle .ico { font-size: 15px; }
    .tv-theme-toggle .lbl { display: none; }
}

/* Tight screens: the arrow alone carries the meaning. */
@media (max-width: 420px) {
    .portal-body .tv-back .tv-back-label { display: none; }
}
