/* Base styles and CSS variables for The Tallow Seal */

/* Color palette from moodboard */
:root {
    --ink: #0d0d0d;          /* Deep black for background and text */
    --parchment: #f8f4e3;    /* Light parchment for UI elements */
    --accent: #c41e3a;       /* Deep red accent for highlights */
    --muted: #6b6b6b;        /* Muted gray for secondary text */
    --highlight: #e8b62b;    /* Gold highlight for interactive elements */
    --candle: #ff9e6b;       /* Candle glow for interactive accents */

    /* Altura reservada para as barras fixas do HUD (topo/rodapé). O palco da
       cena é dimensionado para caber exatamente na faixa livre entre elas. */
    --hud-top-h: 3.6rem;
    --hud-bottom-h: 6.2rem;
}

/* Global reset and fundamentals */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Cormorant Garamond', 'Crimson Pro', serif;
    background-color: var(--ink);
    color: var(--parchment);
    line-height: 1.6;
}

/* O palco (#game-scene) é o único filho em fluxo do body (as barras do HUD e
   o overlay de diálogo são position:fixed). Centralizamos o palco na faixa
   livre entre as barras. */
body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: var(--hud-top-h);
    padding-bottom: var(--hud-bottom-h);
}

/* HUD Top Bar */
.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    border-bottom: 1px solid var(--accent);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.hud-button {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--parchment);
    padding: 0.3rem 0.6rem;
    border-radius: 3px;
    cursor: pointer;
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.hud-button:hover {
    background-color: var(--accent);
    color: var(--ink);
}

/* Main Game Scene — palco com a proporção exata da arte (1280×720 = 16:9).
   Isso garante que os hotspots posicionados em % caiam sobre os elementos da
   imagem, sem o recorte que o `background-size: cover` causava em telas de
   proporção diferente. O palco cresce até caber na faixa livre entre as
   barras do HUD e fica centralizado (letterbox nas sobras). */
#game-scene {
    position: relative;
    z-index: 1;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    width: 100%;
    max-width: calc((100vh - var(--hud-top-h) - var(--hud-bottom-h)) * 16 / 9);
    max-height: calc(100vh - var(--hud-top-h) - var(--hud-bottom-h));
    /* Sem padding: os % dos hotspots passam a medir o palco inteiro (= arte). */
    padding: 0;
}

/* HUD Bottom Bar (Inventory) */
.hud-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    border-top: 1px solid var(--accent);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

/* Escolhas de diálogo (ex.: perguntas a um NPC).
   ATENÇÃO à paleta: a caixa de diálogo (.dialogue-box, em ui.css) é PERGAMINHO
   CLARO (#f8f4e3) com texto escuro. Por isso os botões de escolha usam texto
   ESCURO — antes usavam var(--parchment) e ficavam ilegíveis (texto claro
   sobre fundo claro). O fundo é um leve véu escuro sobre o pergaminho. */
.dialogue-choices {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.dialogue-choice {
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    padding: 0.6rem 0.9rem;
    border-radius: 6px;
    border: 1px solid rgba(13, 13, 13, 0.35);
    /* Fundo PRÓPRIO (não translúcido): o botão fica legível sobre qualquer pai
       — pergaminho claro OU fundo escuro — e não depende do que está atrás. */
    background: #f1ebda;
    color: var(--ink);
    font-size: 0.95rem;
    line-height: 1.35;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.dialogue-choice:hover {
    background: #e3d9bd;
    border-color: var(--accent);
}
.dialogue-choice:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.dialogue-choice:active {
    transform: translateY(1px);
}

.inventory-slot {
    width: 2.1rem;
    height: 2.1rem;
    border: 2px solid var(--parchment);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--parchment);
    background-color: rgba(255,255,255,0.05);
    transition: all 0.2s ease;
}

.inventory-slot:hover {
    border-color: var(--highlight);
    background-color: rgba(255,255,255,0.1);
}

/* Dialogue Overlay */
#dialogue-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#dialogue-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.dialogue-box {
    background-color: var(--parchment);
    color: var(--ink);
    padding: 2rem;
    border-radius: 8px;
    max-width: 80%;
    width: 400px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border: 2px solid var(--accent);
    position: relative;
}

.dialogue-text {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.5;
}

/* Dica de uso de item: o inventário é "selecionar e usar", e sem esta faixa o
   jogador não tinha como saber disso (relato real: "como uso os itens?"). */
.using-hint {
    position: fixed;
    bottom: calc(var(--hud-bottom-h) + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1200;
    max-width: min(760px, 92vw);
    padding: 0.5rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--brass, #8c6f3f);
    background: rgba(13, 11, 9, 0.94);
    color: var(--parchment, #f8f4e3);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.using-hint[hidden] { display: none; }
.using-hint b { color: var(--brass-bright, #d9b75b); }
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .hud-top, .hud-bottom {
        padding: 0.5rem;
    }
    
    .hud-button {
        padding: 0.2rem 0.4rem;
        font-size: 0.8rem;
    }
    
    .inventory-slot {
        width: 2rem;
        height: 2rem;
        font-size: 1rem;
    }
    
    /* O palco mantém a proporção 16:9; só reduzimos a reserva das barras. */
    :root {
        --hud-top-h: 3.1rem;
        --hud-bottom-h: 6.2rem;
    }
}