/* MeatMeet — app inmersiva del cocinero (tablet horizontal).
   Fondo rojo de marca (#c00000). Flujo: sondas → carnes → tacómetro.
   Sin dependencias: CSS + un JS plano. */

:root {
    --red: #c00000;
    --red-deep: #8a0000;
    --ink: #2a0505;
    --white: #fff;
    --glass: rgba(255, 255, 255, .10);
    --glass-2: rgba(255, 255, 255, .16);
    --line: rgba(255, 255, 255, .28);
    --ready: #27d07a;
    --amber: #ffcf5c;
    --shadow: 0 18px 50px rgba(0, 0, 0, .35);
    color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0; height: 100%; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--white);
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

.app {
    height: 100dvh; width: 100vw;
    background:
        radial-gradient(120% 90% at 50% 8%, #e01414 0%, var(--red) 42%, var(--red-deep) 100%);
}

/* Barra de conexión Bluetooth (Web Bluetooth) */
.ble-bar {
    position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 6;
    border: 1px solid rgba(255, 255, 255, .3); border-radius: 999px;
    padding: 9px 18px; font-size: clamp(12px, 1.7vh, 15px); font-weight: 700;
    color: #fff; background: rgba(255, 255, 255, .12); cursor: pointer;
    backdrop-filter: blur(4px); transition: transform .15s, background .2s;
    font-family: inherit;
}
.ble-bar:active { transform: translateX(-50%) scale(.96); }
.ble-ok { background: rgba(39, 208, 122, .22); border-color: var(--ready); }
.ble-busy { background: rgba(255, 207, 92, .2); border-color: var(--amber); }
.ble-warn { background: rgba(0, 0, 0, .3); border-color: rgba(255, 255, 255, .4); cursor: default; }

/* Acceso discreto al back office */
.admin-link {
    position: fixed; bottom: 16px; right: 18px; z-index: 5;
    width: 46px; height: 46px; border-radius: 50%;
    display: grid; place-items: center; text-decoration: none;
    font-size: 22px; background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .25); opacity: .55;
    transition: opacity .2s, transform .15s;
}
.admin-link:active { transform: scale(.9); }
.admin-link:hover { opacity: 1; }

/* Marca de agua: logo grande y tenue de fondo */
.watermark {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: min(80vw, 1000px); height: auto; z-index: 0;
    opacity: .07; pointer-events: none;
    filter: drop-shadow(0 0 1px rgba(0, 0, 0, .2));
}

/* --- Pantallas apiladas con transición fluida ---------------------------- */
.screen {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: clamp(14px, 3vh, 30px);
    padding: clamp(16px, 3vw, 40px);
    opacity: 0; transform: scale(.94); pointer-events: none; z-index: 1;
    transition: opacity .45s ease, transform .55s cubic-bezier(.22, 1, .36, 1);
}
.screen.is-active { opacity: 1; transform: none; pointer-events: auto; }

.brand-logo {
    height: clamp(34px, 7vh, 64px); width: auto;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .3));
    opacity: .96;
}
.hint { color: rgba(255, 255, 255, .8); font-size: clamp(13px, 1.8vh, 18px); margin: 0; font-weight: 500; }
.screen-title { font-size: clamp(20px, 3.4vh, 34px); font-weight: 800; margin: 0; letter-spacing: -.02em; }
.screen-title span { color: var(--amber); }

.back {
    position: absolute; top: clamp(14px, 3vh, 28px); left: clamp(14px, 3vw, 28px);
    width: clamp(46px, 7vh, 62px); height: clamp(46px, 7vh, 62px);
    border-radius: 50%; border: 2px solid var(--line); background: var(--glass);
    color: #fff; font-size: 2rem; line-height: 1; cursor: pointer;
    display: grid; place-items: center; transition: transform .15s, background .2s;
}
.back:active { transform: scale(.9); background: var(--glass-2); }

/* ============================ PANTALLA SONDAS ============================ */
.probes { display: flex; gap: clamp(24px, 6vw, 80px); align-items: flex-start; }
.probe-slot { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.stop-link {
    background: none; border: none; color: rgba(255, 255, 255, .82);
    font-size: clamp(12px, 1.7vh, 16px); font-weight: 600; cursor: pointer;
    padding: 6px 12px; border-radius: 999px; transition: background .2s;
}
.stop-link:active { background: var(--glass); }

.probe {
    --ring: var(--line);
    position: relative;
    width: clamp(200px, 36vh, 340px); aspect-ratio: 1;
    border-radius: 50%; cursor: pointer; padding: 0;
    border: none; background: none;
    animation: pop .5s both;
}
/* disco de cristal detrás de la imagen */
.probe::before {
    content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: 0;
    background: var(--glass); border: 4px solid var(--ring);
    box-shadow: var(--shadow), inset 0 2px 20px rgba(255, 255, 255, .12);
    transition: transform .2s, border-color .3s, background .3s;
}
.probe:active::before { transform: scale(.96); }

/* imagen (carne o sonda) dentro del círculo */
.p-media { position: absolute; inset: 12px; border-radius: 50%; overflow: hidden; z-index: 1; display: grid; place-items: center; }
.p-media img { width: 100%; height: 100%; object-fit: cover; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .35)); }
.p-media.idle img { object-fit: contain; }   /* la sonda: entera (el margen va en el PNG) */

/* anillo de progreso (cocinando) */
.probe .ring-svg { position: absolute; inset: -3px; z-index: 2; transform: rotate(-90deg); pointer-events: none; }
.probe .ring-svg circle { fill: none; stroke-width: 7; }
.probe .ring-svg .bg { stroke: rgba(255, 255, 255, .15); }
.probe .ring-svg .fg { stroke-linecap: round; transition: stroke-dashoffset .6s ease, stroke .6s ease; }

/* texto debajo del círculo */
.p-below { text-align: center; display: flex; flex-direction: column; gap: 1px; }
.p-below .p-name { font-size: clamp(14px, 2vh, 20px); font-weight: 700; opacity: .9; letter-spacing: .01em; }
.p-below .p-temp { font-size: clamp(30px, 6vh, 62px); font-weight: 800; line-height: 1.02; letter-spacing: -.03em; color: #fff; }
.p-below .p-temp .u { font-size: .4em; font-weight: 700; opacity: .7; }
.p-below .p-meat { font-size: clamp(12px, 1.8vh, 18px); font-weight: 600; color: var(--amber); }
.p-below .p-idle { font-size: clamp(12px, 1.7vh, 16px); opacity: .75; font-weight: 600; }
.p-below .p-state { font-size: clamp(11px, 1.5vh, 14px); opacity: .6; }
.p-below.ready .p-temp { color: var(--ready); }

/* estados de la sonda */
.probe.cooking { --ring: var(--amber); }
.probe.off .p-media { opacity: .9; }
.probe.ready { --ring: var(--ready); }
.probe.ready::before { animation: readyPulse 1.1s ease-in-out infinite; }
@keyframes readyPulse {
    0%, 100% { transform: scale(1); box-shadow: var(--shadow), inset 0 2px 20px rgba(255, 255, 255, .12); }
    50% { transform: scale(1.03); box-shadow: 0 0 0 8px rgba(39, 208, 122, .22), var(--shadow); }
}

/* ============================ PANTALLA CARNES ============================ */
.meats {
    display: grid;
    grid-template-columns: repeat(3, var(--meat-size, 200px));   /* JS lo sobreescribe */
    justify-content: center; align-content: center; justify-items: center;
    gap: 22px 40px; max-width: 96vw; padding: 4px;
}
.meat {
    background: none; border: none; cursor: pointer; color: #fff;
    display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.meat .m-circle {
    width: var(--meat-size, 200px); height: var(--meat-size, 200px); aspect-ratio: 1; border-radius: 50%;
    background: radial-gradient(circle at 50% 35%, rgba(255,255,255,.16), rgba(0,0,0,.12));
    border: 4px solid var(--line); overflow: hidden;
    box-shadow: var(--shadow); transition: transform .2s, border-color .25s;
    display: grid; place-items: center;
}
.meat .m-circle img { width: 108%; height: 108%; object-fit: cover; filter: drop-shadow(0 6px 14px rgba(0,0,0,.4)); }
.meat:active .m-circle { transform: scale(.95); }
.meat:hover .m-circle { border-color: var(--amber); }
.meat .m-label { font-size: clamp(13px, 2vh, 21px); font-weight: 800; letter-spacing: .01em; text-align: center; max-width: var(--meat-size, 200px); line-height: 1.15; }
/* entrada escalonada de los medallones */
.screen[data-screen="meats"].is-active .meat { animation: pop .5s both; }
.screen[data-screen="meats"].is-active .meat:nth-child(1) { animation-delay: .03s; }
.screen[data-screen="meats"].is-active .meat:nth-child(2) { animation-delay: .08s; }
.screen[data-screen="meats"].is-active .meat:nth-child(3) { animation-delay: .13s; }
.screen[data-screen="meats"].is-active .meat:nth-child(4) { animation-delay: .18s; }
.screen[data-screen="meats"].is-active .meat:nth-child(5) { animation-delay: .23s; }
.screen[data-screen="meats"].is-active .meat:nth-child(6) { animation-delay: .28s; }

/* ============================ PANTALLA TACÓMETRO ======================== */
.gauge-wrap { display: flex; flex-direction: column; align-items: center; gap: clamp(10px, 2.5vh, 24px); width: min(92vw, 720px); }
.gauge { width: 100%; }
.gauge svg { width: 100%; height: auto; display: block; overflow: visible; }

.g-track { fill: none; stroke: rgba(255, 255, 255, .16); stroke-linecap: round; }
.g-fill { fill: none; stroke: url(#gaugeGrad); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.g-needle { stroke: #fff; stroke-width: 5; stroke-linecap: round; transition: transform .6s cubic-bezier(.22,1,.36,1); transform-origin: 200px 200px; transform-box: view-box; }
.g-hub { fill: #fff; }
.g-tick { stroke: rgba(255,255,255,.5); stroke-width: 2; }
.g-tick.sel { stroke: var(--amber); stroke-width: 4; }
.g-now { fill: #fff; font-weight: 800; }
.g-nowlbl { fill: rgba(255,255,255,.75); font-weight: 600; }

.points { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.point {
    border: 2px solid var(--line); background: var(--glass); color: #fff;
    border-radius: 999px; padding: 10px 16px; cursor: pointer;
    font-weight: 700; font-size: clamp(12px, 1.8vh, 16px);
    display: flex; align-items: center; gap: 8px; transition: transform .15s, background .2s, border-color .2s;
}
.point .p-t { font-size: .85em; opacity: .8; font-weight: 600; }
.point:active { transform: scale(.94); }
.point.sel { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.point.sel .p-t { opacity: .9; }

.cta {
    margin-top: 4px;
    background: #fff; color: var(--red-deep); border: none;
    border-radius: 999px; padding: clamp(14px, 2.4vh, 20px) clamp(30px, 6vw, 60px);
    font-size: clamp(16px, 2.4vh, 22px); font-weight: 800; cursor: pointer;
    box-shadow: var(--shadow); transition: transform .15s, opacity .2s;
}
.cta:active { transform: scale(.96); }
.cta:disabled { opacity: .4; cursor: default; }

/* ============================ AVISO LISTO =============================== */
.alert-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(20, 0, 0, .78); backdrop-filter: blur(6px);
    display: grid; place-items: center; animation: fade .3s both;
}
.alert-overlay[hidden] { display: none; }
.alert-card {
    text-align: center; padding: clamp(24px, 5vh, 50px) clamp(30px, 7vw, 70px);
    background: linear-gradient(180deg, rgba(39,208,122,.2), rgba(0,0,0,.2));
    border: 3px solid var(--ready); border-radius: 28px; box-shadow: var(--shadow);
    animation: pop .45s both;
}
.alert-img {
    width: clamp(150px, 30vh, 280px); height: auto; display: block; margin: 0 auto 6px;
    filter: drop-shadow(0 10px 26px rgba(0, 0, 0, .55)); transform-origin: center;
    animation: readySpin .8s cubic-bezier(.2, .8, .2, 1) both,
               readyFloat 2.6s ease-in-out .9s infinite;
}
@keyframes readySpin {
    0%   { transform: scale(.15) rotate(0deg); opacity: 0; }
    55%  { opacity: 1; }
    100% { transform: scale(1) rotate(360deg); opacity: 1; }
}
@keyframes readyFloat {
    0%, 100% { transform: translateY(0) scale(1); }
    50%      { transform: translateY(-9px) scale(1.03); }
}
.alert-title {
    font-size: clamp(38px, 8vh, 74px); font-weight: 900; color: var(--ready); letter-spacing: .03em;
    animation: readyTitle .5s cubic-bezier(.2, .9, .3, 1.3) .55s both;
}
@keyframes readyTitle {
    0%   { transform: scale(.3); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
.alert-sub { font-size: clamp(16px, 2.6vh, 24px); margin: 8px 0 22px; opacity: .95; }

@keyframes pop {
    from { opacity: 0; transform: scale(.8); }
    to { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Aviso si el móvil/tablet está en vertical */
@media (orientation: portrait) {
    .app::after {
        content: "Gira la tablet en horizontal ↔";
        position: fixed; inset: 0; z-index: 99;
        background: var(--red-deep); color: #fff;
        display: grid; place-items: center; text-align: center;
        font-size: 5vw; font-weight: 700; padding: 10vw;
    }
}
