/* MAIN APP CONTAINER */
#app-shell {
    display: flex; flex-direction: column;
    height: 100%; width: 100%;
    position: relative;
    z-index: 1; /* ensure app content stays above global watermark */
    opacity: 0; /* Made visible with JS */
    transition: opacity 0.8s ease;
}


/* FIXED TOP HEADER */
#top-bar {
    position: fixed; top: 0; left: 0; width: 100%;
    height: var(--header-height);
    background: rgba(8,8,8, 0.92);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px;
    z-index: 500;
}
#header-title { font-weight: 800; font-size: 0.82rem; letter-spacing: 1.8px; text-transform: uppercase; color: rgba(255,255,255,.85); }

/* SCROLL AREA (MAIN CONTENT GOES HERE) */
#viewport {
    flex: 1;
    max-width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 20px;
    /* Leave space so the bars do not cover the content */
    padding-top: calc(var(--header-height) + 20px);
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 20px);

    /* Anchor absolute brand marks inside the viewport (below the fixed top-bar). */
    position: relative;
}

/* Bottom nav styles are defined in components.css
   (single liquid-glass pill that clips its scrolling content). */

/* ============================================================
   SPLASH v2 — "La cocina enciende"
   Secuencia: fondo ambiental (kenburns) → brasas → logo con halo
   y barrido de luz → wordmark → shimmer de carga → salida curtain.
   El PNG nativo de iOS replica el frame inicial para un handoff
   sin costura (mismo fondo, logo centrado).
   ============================================================ */
#security-layer {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: #0B0805;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    --splash-exit-ms: 900ms;
    --splash-shadow-ms: 620ms;
    --spl-gold: #E8B25C;
    --spl-gold-hi: #FFE0AC;
    --spl-ink: #F2E7D4;
    will-change: transform, opacity;
}

#security-layer .spl-bg{
    position: absolute; inset: -4%;
    background: #0B0805 url('../img/brand/ra_splash_bg.webp') center/cover no-repeat;
    animation: splBgIn 3s ease-out both;
}
#security-layer .spl-bg::after{
    content:''; position:absolute; inset:0;
    background: radial-gradient(92% 62% at 50% 44%, rgba(0,0,0,.10) 0%, rgba(0,0,0,.58) 100%);
}
@keyframes splBgIn{
    0%   { transform: scale(1.07); opacity: 0; }
    28%  { opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* brasas que suben (spans inyectados por el script inline del index) */
#security-layer .spl-embers{ position:absolute; inset:0; pointer-events:none; }
#security-layer .spl-embers i{
    position:absolute; bottom:-14px; left:var(--x,50%);
    width:4px; height:4px; border-radius:50%;
    background: radial-gradient(circle, #FFDCA6 0%, #E8A24C 55%, rgba(232,162,76,0) 78%);
    filter: drop-shadow(0 0 6px rgba(240,170,80,.85));
    opacity:0;
    animation: splEmber var(--d,7s) linear var(--dl,0s) infinite;
}
@keyframes splEmber{
    0%   { transform: translate3d(0,0,0) scale(var(--s,1)); opacity:0; }
    8%   { opacity:.9; }
    62%  { opacity:.5; }
    100% { transform: translate3d(var(--dx,0px), -104vh, 0) scale(calc(var(--s,1)*.45)); opacity:0; }
}

/* núcleo: logo + halo + anillo de barrido + wordmark */
#security-layer .spl-core{
    position: relative;
    display: flex; flex-direction: column; align-items: center;
    transform: translateY(-3.5vh);
}
#security-layer .spl-logoWrap{
    position: relative;
    width: clamp(158px, 42vw, 236px);
    aspect-ratio: 838 / 896;
}
#security-layer .spl-halo{
    position: absolute; inset: -46%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240,178,92,.34) 0%, rgba(240,178,92,.12) 40%, transparent 68%);
    filter: blur(6px);
    animation: splHalo 3.4s ease-in-out 1.1s infinite;
    opacity:.55;
}
@keyframes splHalo{
    0%,100% { opacity:.5;  transform: scale(1); }
    50%     { opacity:1;   transform: scale(1.09); }
}
#security-layer .spl-logo{
    position: relative; z-index: 2;
    width: 100%; height: 100%; display:block; object-fit: contain;
    filter:
      drop-shadow(0 0 26px rgba(240,178,92,.5))
      drop-shadow(0 0 70px rgba(240,178,92,.22))
      drop-shadow(0 20px 44px rgba(0,0,0,.6));
    animation: splLogoIn 1.1s cubic-bezier(.2,.9,.25,1.18) .12s both;
}
@keyframes splLogoIn{
    0%   { transform: scale(.82); opacity: 0; }
    55%  { opacity: 1; }
    100% { transform: scale(1);   opacity: 1; }
}
/* barrido de luz que orbita el sello (2 vueltas y se apaga) */
#security-layer .spl-ring{
    position: absolute; inset: -16%;
    z-index: 1; border-radius: 50%;
    opacity: 0;
    animation: splRingSpin 2.3s cubic-bezier(.55,.12,.25,1) .5s 2 both;
}
#security-layer .spl-ring::before{
    content:''; position:absolute; inset:0; border-radius:inherit;
    padding: 1.6px;
    background: conic-gradient(from 0deg, transparent 0 68%, rgba(255,216,150,.95) 86%, transparent 100%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask-composite: exclude;
}
@keyframes splRingSpin{
    0%   { transform: rotate(0deg);   opacity: 0; }
    10%  { opacity: 1; }
    88%  { opacity: 1; }
    100% { transform: rotate(360deg); opacity: 0; }
}

#security-layer .spl-word{
    margin-top: 27px;
    font-family: var(--font-ui, Manrope, system-ui, sans-serif);
    font-weight: 900;
    letter-spacing: .34em; text-indent: .34em;
    font-size: clamp(.98rem, 3.5vw, 1.28rem);
    color: var(--spl-ink);
    text-shadow: 0 10px 34px rgba(0,0,0,.78);
    animation: splUp .9s ease .55s both;
}
#security-layer .spl-sub{
    margin-top: 9px;
    font-family: var(--font-ui, Manrope, system-ui, sans-serif);
    font-size: clamp(.58rem, 2vw, .7rem);
    letter-spacing: .3em; text-indent: .3em;
    text-transform: uppercase; font-weight: 800;
    color: rgba(242,231,212,.62);
    animation: splUp .9s ease .8s both;
}
@keyframes splUp{
    0%   { transform: translateY(14px); opacity: 0; }
    100% { transform: translateY(0);    opacity: 1; }
}
#security-layer .spl-bar{
    margin-top: 30px;
    width: min(200px, 46vw); height: 2px; border-radius: 2px;
    background: rgba(255,255,255,.12);
    overflow: hidden;
    animation: splUp .8s ease 1.05s both;
}
#security-layer .spl-bar i{
    display:block; height:100%; width:44%; border-radius:2px;
    background: linear-gradient(90deg, transparent, var(--spl-gold) 40%, var(--spl-gold-hi) 60%, transparent);
    animation: splShimmer 1.5s ease-in-out 1.2s infinite;
}
@keyframes splShimmer{
    0%   { transform: translateX(-115%); }
    100% { transform: translateX(360%); }
}

/* Handoff nativo: el PNG del splash de iOS replica este mismo frame,
   así que se mantiene el contenido (antes se forzaba negro puro). */
#security-layer.native-handoff {
    --splash-exit-ms: 480ms;
    --splash-shadow-ms: 300ms;
}

/* sombra de "telón" al salir (se conserva del diseño anterior) */
#security-layer::before{
    content: '';
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    background:
      linear-gradient(180deg, rgba(0,0,0,0.30) 0%, rgba(0,0,0,0.10) 20%, rgba(0,0,0,0.00) 42%),
      linear-gradient(0deg, rgba(0,0,0,0.18) 0%, rgba(0,0,0,0.00) 22%);
}

.hidden-layer{
    pointer-events: none;
    animation: splashFadeOut var(--splash-exit-ms) ease-out forwards;
}
.hidden-layer::before{
    opacity: 1;
    animation: splashShadowLift var(--splash-shadow-ms) ease-out forwards;
}
.hidden-layer .spl-core{
    animation: splCoreOut 460ms ease-in both;
}
@keyframes splCoreOut{
    to { transform: translateY(-7vh) scale(.94); opacity: 0; }
}

/* accesibilidad: sin animaciones si el sistema lo pide */
@media (prefers-reduced-motion: reduce){
    #security-layer .spl-bg,
    #security-layer .spl-core,
    #security-layer .spl-logo,
    #security-layer .spl-word,
    #security-layer .spl-sub,
    #security-layer .spl-bar,
    #security-layer .spl-bar i,
    #security-layer .spl-halo,
    #security-layer .spl-ring{ animation: none !important; }
    #security-layer .spl-ring{ opacity: 0 !important; }
    #security-layer .spl-embers{ display: none; }
}

.layer-gone{
    opacity: 0;
    visibility: hidden;
    display: none;
}

@keyframes splashShadowLift{
    0%   { opacity: 0.42; }
    100% { opacity: 0; }
}

@keyframes splashFadeOut{
    0%   { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes splashExit{
    0%   { transform: translate3d(0, 0, 0); opacity: 1; }
    55%  { transform: translate3d(0, -8%, 0); opacity: 1; }
    100% { transform: translate3d(0, -112%, 0); opacity: 0; }
}

/* BRAND MARKS (subtle, premium) */
.brand-mini{
    width: 34px;
    height: auto;
    opacity: 0.9;
    filter: drop-shadow(0 8px 18px rgba(0,0,0,0.25));
}

/* Visible section branding (clean, aligned)
   Use the header logo (transparent PNG). */
.brand-section-row{
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin: 8px 0 8px;
    padding-right: 14px;
}

.brand-section{
    width: clamp(96px, 18vw, 132px);
    height: auto;
    display: block;
    opacity: 0.78;
    filter: none;
}


/* Brew header brand overlay (does NOT push content) */
.brew-hero{
    position: relative;
}
.brew-hero .brand-section-row{
    position: absolute;
    right: 12px;
    bottom: -4px;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none;
    z-index: 0;
}
.brew-hero .brand-section{
    width: clamp(92px, 18vw, 128px);
    opacity: 0.16;
}
.brew-hero > *:not(.brand-section-row){
    position: relative;
    z-index: 1;
}

/* Dashboard brand handled as subtle background in dash hero */

.dash-brand img{
    width: clamp(170px, 50vw, 250px);
    height: auto;
    display: block;
    opacity: 0.92;
}
/* Bottom nav label display is handled in components.css (active only) */
#bottom-nav .nav-item span{ display:none; }
#bottom-nav .nav-item.active span{ display:block; }

/* Brew: remove extra 20px gap under fixed top-bar so the sticky method bar sits flush.
   Applied dynamically by BrewController when viewing a method or recipe detail. */
#viewport.brew-tight-top{
    padding-top: var(--header-height);
}

/* Home: reduce top padding so the hero photo extends closer to the top bar.
   Applied by Router when entering Home route. */
#viewport.home-tight-top{
    padding-top: var(--header-height);
}


/* =====================================================================
   RESPONSIVE LAYOUT OVERRIDES
   ===================================================================== */
#app-shell {
    min-height: var(--app-height, 100dvh);
    height: var(--app-height, 100dvh);
    width: min(100%, var(--app-max-width));
    margin: 0 auto;
}

#top-bar {
    left: 50%;
    transform: translateX(-50%);
    width: min(100%, var(--app-max-width));
    min-height: var(--header-height);
    height: var(--header-height);
    padding-top: var(--safe-area-top);
    padding-right: calc(var(--viewport-pad-x) + var(--safe-area-right));
    padding-left: calc(var(--viewport-pad-x) + var(--safe-area-left));
}

#viewport {
    width: min(100%, var(--app-max-width));
    margin: 0 auto;
    padding-left: var(--viewport-pad-x);
    padding-right: var(--viewport-pad-x);
    padding-top: calc(var(--header-height) + var(--viewport-pad-top-gap));
    padding-bottom: calc(var(--nav-base-height) + var(--safe-area-bottom) + var(--viewport-pad-bottom-gap));
    scroll-padding-top: calc(var(--header-height) + 18px);
    scroll-padding-bottom: calc(var(--nav-base-height) + var(--safe-area-bottom) + 28px);
}

#viewport.brew-tight-top,
#viewport.home-tight-top {
    padding-top: var(--header-height);
}

body.keyboard-open #viewport {
    padding-bottom: 24px;
}
