/* Ecrã de espera do cofre: o mostrador de um cofre a ser aberto.
   Partilhado pela página inicial, porta, clássico, Beta e admin: o HTML é igual
   em todas (.vista-roda com 12 <i>), por isso o aspeto muda só aqui. */
.cofre-loading {
    --cl-papel: #f4f1ea;
    --cl-linha: #dad5c7;
    --cl-tinta: #17231c;
    --cl-suave: #56655b;
    --cl-verde: #15803d;
    --cl-verde-escuro: #14532d;
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    background-color: var(--cl-papel);
    background-image:
        linear-gradient(var(--cl-linha) 1px, transparent 1px),
        linear-gradient(90deg, var(--cl-linha) 1px, transparent 1px);
    background-size: 44px 44px;
}
/* Esbate a grelha nas bordas, como no topo da página inicial. */
.cofre-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 45%, rgba(244, 241, 234, 0) 0%, var(--cl-papel) 72%);
}
.cofre-loading > * {
    position: relative;
}
.cofre-loading.hidden {
    display: none;
    content-visibility: hidden;
}
.cofre-loading.hidden .vista-roda i {
    animation: none;
}
.cofre-loading-texto {
    margin: 0;
    /* Só tipos do sistema: nem o Beta, nem o clássico, nem a porta carregam a
       JetBrains Mono, e o texto não pode mudar de letra ao trocar de página. */
    font-family: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--cl-suave);
}

/* Mostrador: aro, 12 marcas que acendem em sequência e o miolo do cofre.
   As marcas estão a 30° umas das outras no sentido horário; os atrasos negativos
   crescem de 0.1s por marca (0, -1.1s, -1s ... -0.1s) para a luz acompanhar
   essa ordem. Com atrasos a descer (0, -0.1s, -0.2s ...) a roda girava ao contrário. */
.vista-roda {
    width: 84px;
    height: 84px;
    position: relative;
    border-radius: 50%;
    background: #fffdf8;
    border: 2px solid var(--cl-linha);
    box-shadow: 0 14px 28px -14px rgba(23, 35, 28, 0.5), inset 0 0 0 5px #fffdf8, inset 0 0 0 6px var(--cl-linha);
}
/* Pino de mapa verde no centro (a ponta aponta para baixo). */
.vista-roda::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    margin: -15px 0 0 -11px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: radial-gradient(circle at 50% 50%, #fffdf8 0 3.5px, var(--cl-verde) 4px);
    box-shadow: inset 0 0 0 1.5px var(--cl-verde-escuro);
    animation: vista-pino 1.2s ease-in-out infinite;
}
@keyframes vista-pino {
    0%, 100% { margin-top: -15px; }
    50% { margin-top: -19px; }
}
.vista-roda i {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 3px;
    height: 10px;
    margin: -5px 0 0 -1.5px;
    border-radius: 2px;
    background: var(--cl-verde);
    opacity: 0.14;
    animation: vista-dot 1.2s linear infinite;
}
.vista-roda i:nth-child(1) { transform: rotate(0deg) translateY(-28px); animation-delay: 0s; }
.vista-roda i:nth-child(2) { transform: rotate(30deg) translateY(-28px); animation-delay: -1.1s; }
.vista-roda i:nth-child(3) { transform: rotate(60deg) translateY(-28px); animation-delay: -1s; }
.vista-roda i:nth-child(4) { transform: rotate(90deg) translateY(-28px); animation-delay: -0.9s; }
.vista-roda i:nth-child(5) { transform: rotate(120deg) translateY(-28px); animation-delay: -0.8s; }
.vista-roda i:nth-child(6) { transform: rotate(150deg) translateY(-28px); animation-delay: -0.7s; }
.vista-roda i:nth-child(7) { transform: rotate(180deg) translateY(-28px); animation-delay: -0.6s; }
.vista-roda i:nth-child(8) { transform: rotate(210deg) translateY(-28px); animation-delay: -0.5s; }
.vista-roda i:nth-child(9) { transform: rotate(240deg) translateY(-28px); animation-delay: -0.4s; }
.vista-roda i:nth-child(10) { transform: rotate(270deg) translateY(-28px); animation-delay: -0.3s; }
.vista-roda i:nth-child(11) { transform: rotate(300deg) translateY(-28px); animation-delay: -0.2s; }
.vista-roda i:nth-child(12) { transform: rotate(330deg) translateY(-28px); animation-delay: -0.1s; }
@keyframes vista-dot {
    0% { opacity: 1; }
    100% { opacity: 0.14; }
}
@media (prefers-reduced-motion: reduce) {
    .vista-roda i,
    .vista-roda::after { animation: none; }
    .vista-roda i { opacity: 0.55; }
}

/* Sessão guardada: o ecrã de espera cobre a página desde o primeiro desenho
   (js/sessao-guardada.js põe a classe no <html>, na página inicial e na porta). */
html.sessao-guardada #cofre-loading.hidden { display: flex; content-visibility: visible; }
html.sessao-guardada #cofre-loading.hidden .vista-roda i { animation-name: vista-dot; }
html.sessao-guardada { overflow: hidden; }
