*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #070d16;
    --panel: #0b131f;
    --card: #101a28;
    --line: rgba(255, 255, 255, 0.1);
    --text: #fff;
    --muted: rgba(255, 255, 255, 0.62);
    --accent: #f6c91f;
    --status: #2fe0a0;
}

/* 1rem = 16px em 1920x1080; todo o layout escala junto com a resolução da TV. */
html {
    font-size: max(7px, min(0.8333vw, 1.4815vh));
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Roboto, 'Noto Sans', system-ui, -apple-system, sans-serif;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.hidden {
    display: none !important;
}

#display-shell {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 9.6rem;
    background: var(--bg);
}

/* ---------- Banner principal ---------- */

#banner-stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: #000;
}

#slideshow-container {
    position: absolute;
    inset: 0;
    background: #000;
}

.slide {
    position: absolute;
    inset: 0;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    background: #05080d;
}

.slide.active {
    opacity: 1;
    z-index: 1;
}

.slide-backdrop {
    position: absolute;
    inset: -6%;
    width: 112%;
    height: 112%;
    object-fit: cover;
    filter: blur(2.2rem) brightness(0.38);
}

.slide-media {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

video.slide-media {
    background: #000;
}

.slide.media-error {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #191919;
}

.slide.media-error > * {
    display: none;
}

.slide.media-error::after {
    content: 'Mídia indisponível';
    color: rgba(255, 255, 255, 0.55);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#dots-container {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0.9rem;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
}

.dot {
    position: relative;
    width: 0.7rem;
    height: 0.7rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.45);
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    transition: width 0.35s ease;
}

/* O banner em exibição vira uma barra que enche conforme o tempo de tela. */
.dot.active {
    width: 6.5rem;
    background: rgba(255, 255, 255, 0.35);
}

.dot.active::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--accent);
    transform-origin: left center;
    animation: dot-progress var(--slide-duration, 15s) linear both;
}

@keyframes dot-progress {
    from { transform: scaleX(0.1); }
    to { transform: scaleX(1); }
}

/* ---------- Notícias no carrossel ---------- */

.news-slide .slide-backdrop {
    filter: blur(2.6rem) brightness(0.26);
}

.news-slide-inner {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    padding: 2.4rem 3rem 3.6rem;
}

/* A foto ocupa a altura que sobrar depois do texto. */
.news-slide-image {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    object-fit: cover;
    border-radius: 1rem;
    box-shadow: 0 1.2rem 3rem rgba(0, 0, 0, 0.55);
    background: rgba(255, 255, 255, 0.08);
}

.news-slide-body {
    flex: none;
    min-width: 0;
}

.news-slide-tag {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--accent);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.news-slide-tag::after {
    content: '';
    width: 5.2rem;
    height: 0.18rem;
    border-radius: 999px;
    background: var(--accent);
}

.news-slide-title {
    max-height: calc(1.16em * 3);
    margin-top: 1rem;
    font-size: 2.7rem;
    line-height: 1.16;
    font-weight: 800;
    text-shadow: 0 0.15rem 0.8rem rgba(0, 0, 0, 0.6);
}

.news-slide-text {
    max-height: calc(1.38em * 4);
    margin-top: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.55rem;
    line-height: 1.38;
}

.news-slide-meta {
    margin-top: 1.1rem;
    color: var(--muted);
    font-size: 1.25rem;
}

/* ---------- Avisos do condomínio ---------- */

#notices-panel {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1.6rem;
    padding: 2rem 2rem 1.6rem;
    background: var(--panel);
    border-left: 1px solid var(--line);
    overflow: hidden;
}

.section-title {
    flex: none;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.section-title::after {
    content: '';
    flex: 1;
    max-width: 5.2rem;
    height: 0.18rem;
    border-radius: 999px;
    background: var(--accent);
}

#notices-list {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    font-size: 1.5rem;
    line-height: 1.4;
    overflow: hidden;
}

.empty-notices {
    margin: auto;
    padding: 2rem;
    color: var(--muted);
    font-size: 1.5rem;
    text-align: center;
}

/* ---------- Texto longo com rolagem suave ---------- */

.auto-scroll {
    overflow: hidden;
}

.auto-scroll > span {
    display: block;
}

.auto-scroll.is-scrolling > span {
    animation: auto-scroll var(--scroll-time, 12s) ease-in-out infinite;
}

@keyframes auto-scroll {
    0%, 22% { transform: translateY(0); }
    48%, 74% { transform: translateY(var(--scroll-shift, 0)); }
    96%, 100% { transform: translateY(0); }
}

/* ---------- Rodapé ---------- */

#environment-footer {
    grid-column: 1 / -1;
    min-height: 0;
    display: flex;
    align-items: stretch;
    padding: 1.2rem max(1.7rem, env(safe-area-inset-right, 0px))
             calc(1.2rem + env(safe-area-inset-bottom, 0px))
             max(1.7rem, env(safe-area-inset-left, 0px));
    background: var(--bg);
    border-top: 1px solid var(--line);
    overflow: hidden;
}

.environment-item {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    padding: 0 1.6rem;
    border-left: 1px solid var(--line);
    min-width: 0;
}

.environment-item:first-child {
    padding-left: 0.6rem;
    border-left: 0;
}

.environment-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.environment-label {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.environment-icon {
    flex: none;
    width: 3.1rem;
    height: 3.1rem;
    color: var(--text);
}

.environment-icon.icon-accent {
    color: var(--accent);
}

.environment-icon.icon-status {
    color: var(--status);
}

.environment-location {
    flex: 0 1 auto;
    max-width: 24rem;
}

#location-name {
    font-size: 1.5rem;
    line-height: 1.15;
    font-weight: 700;
}

.environment-weather {
    flex: none;
}

#weather-icon {
    flex: none;
    width: 5rem;
    height: 5rem;
}

#weather-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.wx-sun { fill: var(--accent); }
.wx-ray { stroke: var(--accent); stroke-width: 3.4; stroke-linecap: round; fill: none; }
.wx-cloud { fill: #fff; }
.wx-line { stroke: rgba(255, 255, 255, 0.75); stroke-width: 3.4; stroke-linecap: round; fill: none; }
.wx-drop { stroke: #6cc4ff; stroke-width: 3.4; stroke-linecap: round; fill: none; }
.wx-bolt { fill: var(--accent); }

#weather-temp {
    font-size: 3.7rem;
    line-height: 1;
    font-weight: 800;
    white-space: nowrap;
}

.weather-details {
    gap: 0.15rem;
    white-space: nowrap;
}

#weather-condition {
    font-size: 1.05rem;
    font-weight: 700;
}

#weather-range,
#weather-updated {
    color: var(--muted);
    font-size: 0.98rem;
}

.environment-date-time,
.environment-quotes,
.environment-status {
    flex: none;
    white-space: nowrap;
}

#footer-date {
    font-size: 1.4rem;
    line-height: 1.2;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

#footer-time {
    color: var(--accent);
    font-size: 2.1rem;
    line-height: 1.05;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.quote-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.35;
}

.quote-row strong {
    color: var(--text);
    font-size: 1.4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

#footer-status {
    color: var(--status);
    font-size: 1.6rem;
    line-height: 1.2;
    font-weight: 800;
}

.environment-notice {
    flex: 1 1 0;
    min-width: 16rem;
    padding-right: 0.6rem;
}

.environment-notice .environment-text {
    flex: 1;
}

#banner-title {
    max-height: calc(1.18em * 2);
    font-size: 1.45rem;
    line-height: 1.18;
    font-weight: 800;
}

#banner-description {
    max-height: calc(1.3em * 2);
    margin-top: 0.35rem;
    color: rgba(255, 255, 255, 0.82);
    font-size: 1.02rem;
    line-height: 1.3;
}

/* ---------- Carregamento e erro ---------- */

#loading,
#error {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #050505;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.4rem;
    padding: 2.5rem;
    text-align: center;
}

.spinner {
    width: 3.8rem;
    height: 3.8rem;
    border: 0.3rem solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text,
#error-message {
    color: rgba(255, 255, 255, 0.72);
    font-size: 1.3rem;
    line-height: 1.5;
    max-width: 40rem;
    white-space: pre-line;
}

.error-icon {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    border: 0.2rem solid #e25555;
    color: #e25555;
    font-size: 2.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

#retry-button {
    margin-top: 0.5rem;
    padding: 0.9rem 1.9rem;
    font-size: 1.1rem;
    font-weight: 800;
    color: #071018;
    background: var(--accent);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    text-transform: uppercase;
}

#retry-button:active {
    transform: scale(0.97);
}

/* ---------- TV na vertical ---------- */

@media (orientation: portrait) {
    html {
        font-size: max(7px, 1.4815vw);
    }

    #display-shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 2fr) minmax(0, 1fr) auto;
    }

    #notices-panel {
        border-left: 0;
        border-top: 1px solid var(--line);
    }

    #environment-footer {
        display: grid;
        grid-template-columns: auto auto minmax(0, 1fr);
        row-gap: 1.4rem;
    }

    .environment-item {
        min-height: 6.4rem;
    }

    .environment-location {
        max-width: none;
    }

    .environment-weather {
        grid-column: 2 / -1;
    }

    .environment-date-time {
        padding-left: 0.6rem;
        border-left: 0;
    }

    .environment-notice {
        grid-column: 1 / -1;
        padding-left: 0.6rem;
        border-left: 0;
    }
}
