@import url('./critical-tokens.css');
@import url('./styles.animations.css');

/* Zephyria Client Styles */

/* -----------------------------------------------------------------------
   Unified layout map — single source of truth for bottom-strip geometry.
   All bottom-strip elements (menu bar, action bar, chat, WHN, d-pad) read
   from these vars so a single change propagates everywhere.
   ----------------------------------------------------------------------- */
:root {
    /* Inset from the physical bottom of the viewport (menu bar); tighter than side margins */
    --strip-bottom-margin: 5px;
    /* Height of the menu bar strip at the very bottom */
    --strip-menu-h: 50px;
    /* Legacy calc (action bar and docs). */
    --strip-above-menu: calc(var(--strip-bottom-margin) + var(--strip-menu-h));
    /* Horizontal margin from screen edge used by chat, WHN, d-pad */
    --strip-side-margin: 20px;
    /* Horizontal padding inside full-width bars (keeps buttons clear of d-pad) */
    --strip-h-padding: 80px;
}

/* Density: tighten spacing on narrow viewports (≤ 768 px) */
@media (max-width: 768px) {
    :root {
        --strip-h-padding: 16px;
    }
}

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--ui-body-bg);
    color: var(--ui-body-fg);
    height: 100vh;
    width: 100vw;
}

/* -------------------------------------------------------------------------- */
/* Center Dialogue Overlay (NPC -> Player)                                     */
/* warcraftcn-style chrome: same asset URLs as third_party/warcraftcn-ui       */
/* components/ui/warcraftcn/styles/warcraft.css (Card + Button 9-slice)       */
/* -------------------------------------------------------------------------- */

.center-dialogue-overlay {
    /* Vendored from warcraftcn-ui (MIT) — files in client/assets/ui/warcraftcn/ */
    --wc-card-bg: url("../assets/ui/warcraftcn/card-bg.webp");
    --wc-btn-bg: url("../assets/ui/warcraftcn/button-bg.webp");
    --cdo-border: 24px;
    --cdo-pad-x: 20px;
    --cdo-pad-y: 16px;
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(10px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px))
        max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    box-sizing: border-box;
    z-index: 999999; /* above "what's happening now" and all HUD */
    pointer-events: none; /* card handles pointer events */
}

/* Vignette behind panel (does not steal clicks) */
.center-dialogue-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(ellipse 85% 75% at 50% 42%, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.72) 100%);
}

.center-dialogue-overlay .cdo-card {
    position: relative;
    z-index: 1;
    pointer-events: auto;
    width: min(820px, 100%);
    max-height: min(85vh, 620px);
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: var(--cdo-pad-y) var(--cdo-pad-x) calc(var(--cdo-pad-y) - 2px);
    overflow: hidden;
    /* WC3 panel frame — matches warcraftcn-ui Card (wc-card-border + slice 24) */
    border-style: solid;
    border-width: var(--cdo-border);
    border-image-source: var(--wc-card-bg);
    border-image-slice: 24 fill;
    border-image-repeat: stretch;
    background: linear-gradient(180deg, hsl(35 15% 9% / 0.97) 0%, hsl(28 12% 7% / 0.98) 100%);
    box-shadow:
        0 0 0 1px hsl(45 35% 18% / 0.35),
        0 24px 56px hsl(0 0% 0% / 0.75),
        inset 0 1px 0 hsl(45 40% 35% / 0.12);
}

.center-dialogue-overlay .cdo-header {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 2px;
}

.center-dialogue-overlay .cdo-actions {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(112px, 100%), 1fr));
    gap: 8px;
    align-items: stretch;
}

/* warcraftcn Button default variant — wc-btn-border + slice 16 */
.center-dialogue-overlay .cdo-action {
    font-family: 'Cinzel', serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    line-height: 1.25;
    padding: 8px 10px;
    min-height: 40px;
    border-style: solid;
    border-width: 5px;
    border-image-source: var(--wc-btn-bg);
    border-image-slice: 16 fill;
    border-image-repeat: stretch;
    background: transparent;
    color: #fffef8;
    text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85);
    cursor: pointer;
    text-align: center;
    white-space: normal;
    word-break: break-word;
    transition: filter 0.12s ease, transform 0.08s ease;
}

.center-dialogue-overlay .cdo-action:hover:not(:disabled) {
    filter: brightness(1.12);
}

.center-dialogue-overlay .cdo-action:active:not(:disabled) {
    transform: scale(0.98);
    filter: brightness(0.88);
}

.center-dialogue-overlay .cdo-action:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.35);
}

.center-dialogue-overlay .cdo-npc {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    letter-spacing: 0.05em;
    font-size: clamp(16px, 2.8vw, 20px);
    color: #f4ecd4;
    text-shadow:
        0 0 12px hsl(45 80% 40% / 0.35),
        0 2px 4px hsl(0 0% 0% / 0.9);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.center-dialogue-overlay .cdo-transcript {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
    border-radius: 4px;
    background: linear-gradient(180deg, hsl(35 12% 6% / 0.95) 0%, hsl(28 10% 5% / 0.98) 100%);
    border: 1px solid hsl(45 30% 22% / 0.45);
    box-shadow: inset 0 0 20px hsl(0 0% 0% / 0.45);
}

/* Interaction-only / no lines yet: don't reserve a tall empty transcript band */
.center-dialogue-overlay .cdo-transcript:empty {
    display: none;
    flex: 0 0 0;
    min-height: 0;
    padding: 0;
    border: none;
}

.center-dialogue-overlay .cdo-transcript:not(:empty) {
    min-height: 3.5rem;
}

.center-dialogue-overlay .cdo-line {
    font-family: 'Inter', sans-serif;
    font-size: clamp(13px, 1.65vw, 15px);
    line-height: 1.45;
    color: #ebe6dc;
    margin: 0 0 8px 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.center-dialogue-overlay .cdo-player {
    color: #b8d9ff;
}

.center-dialogue-overlay .cdo-options {
    flex: 0 1 auto;
    min-height: 0;
    max-height: min(240px, 38vh);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.center-dialogue-overlay .cdo-option {
    font-family: 'Cinzel', serif;
    font-size: clamp(12px, 1.8vw, 14px);
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 10px 12px;
    min-height: 44px;
    flex-shrink: 0;
    border-style: solid;
    border-width: 5px;
    border-image-source: var(--wc-btn-bg);
    border-image-slice: 16 fill;
    border-image-repeat: stretch;
    background: transparent;
    color: #fffef8;
    text-shadow: 0 1px 2px hsl(0 0% 0% / 0.85);
    cursor: pointer;
    text-align: left;
    overflow-wrap: anywhere;
    transition: filter 0.12s ease, transform 0.08s ease;
}

.center-dialogue-overlay .cdo-option:hover {
    filter: brightness(1.12);
}

.center-dialogue-overlay .cdo-option:active {
    transform: scale(0.995);
    filter: brightness(0.9);
}

.center-dialogue-overlay .cdo-loading {
    flex: 0 0 auto;
    font-family: 'Cinzel', serif;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: hsl(45 55% 72%);
}

.center-dialogue-overlay .cdo-hint {
    flex: 0 0 auto;
    font-family: 'Cinzel', serif;
    font-size: 10px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: hsl(45 25% 55% / 0.9);
    line-height: 1.35;
}

@media (max-width: 520px) {
    .center-dialogue-overlay {
        --cdo-border: 18px;
        --cdo-pad-x: 14px;
        --cdo-pad-y: 12px;
    }

    .center-dialogue-overlay .cdo-actions {
        grid-template-columns: repeat(auto-fill, minmax(min(100px, 100%), 1fr));
        gap: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .center-dialogue-overlay .cdo-action,
    .center-dialogue-overlay .cdo-option {
        transition: none;
    }
}

