/* =========================================================
   Mi IMC · Calculadora de Índice de Masa Corporal
   HTML + CSS + JS sin dependencias
   ========================================================= */

/* ---------- 1. Tokens ---------- */
:root{
  --blue:#1A5FAE;
  --blue-dark:#144C8C;
  --blue-deep:#0F3A6B;
  --blue-100:#E8F0FA;
  --blue-50:#F3F8FD;
  --orange:#F7941D;
  --orange-dark:#A85F00;
  --orange-soft:#FFF1DE;
  --ink:#16263A;
  --muted:#5E7089;
  --line:#DFE8F3;
  --surface:#FFFFFF;
  --bg:#F2F6FB;
  --green:#2E9E6B;
  --amber:#E0A100;
  --red:#B3261E;
  --radius:20px;
  --shadow:0 14px 34px -26px rgba(16,52,96,.55);
  --ease:cubic-bezier(.2,.7,.3,1);
  --sans:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}

/* ---------- 2. Reset ---------- */
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;
  background:var(--bg);
  background-image:radial-gradient(900px 480px at 80% -10%,#E9F2FC,transparent 70%);
  color:var(--ink);
  font-family:var(--sans);
  font-size:16px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
  min-height:100vh;
  min-height:100dvh;
}
h1,h2,h3,p,figure,dl,dd{margin:0}
ul{list-style:none;padding:0}
a{color:inherit}
button{font:inherit;color:inherit}
svg{display:block}
[hidden]{display:none !important}
:focus-visible{outline:2px solid var(--blue);outline-offset:2px;border-radius:8px}

.sprite{position:absolute;width:0;height:0;overflow:hidden}
.i{
  width:22px;height:22px;flex:none;
  fill:none;stroke:currentColor;stroke-width:1.7;
  stroke-linecap:round;stroke-linejoin:round;
}

/* ---------- 3. Estructura ---------- */
.shell{display:block;min-height:100vh;min-height:100dvh}
.main{display:flex;flex-direction:column;min-height:100vh;min-height:100dvh;min-width:0}
.content{flex:1;display:flex;flex-direction:column}

/* ---------- 4. Sidebar / drawer ---------- */
.sidebar{
  position:fixed;
  top:0;left:0;bottom:0;
  z-index:50;
  width:min(84vw,310px);
  display:flex;
  flex-direction:column;
  gap:22px;
  padding:18px 14px calc(18px + env(safe-area-inset-bottom));
  background:var(--surface);
  border-right:1px solid var(--line);
  transform:translateX(-102%);
  visibility:hidden;
  transition:transform .28s var(--ease),visibility .28s;
  overflow-y:auto;
}
.sidebar.is-open{transform:none;visibility:visible}

.sidebar__head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:2px 4px}
.sidebar__close{display:grid}

.brand{display:flex;align-items:center;gap:10px;text-decoration:none;color:inherit;min-width:0}
.brand__mark{
  display:grid;place-items:center;
  width:40px;height:40px;flex:none;
  border-radius:13px;
  background:var(--blue);
  color:#fff;
}
.brand__mark .i{width:21px;height:21px;stroke-width:2}
.brand__text{display:grid;gap:1px;min-width:0}
.brand__text strong{font-size:15px;font-weight:750;letter-spacing:-.01em}
.brand__text small{font-size:10.5px;color:var(--muted);letter-spacing:.02em}
.brand--compact .brand__mark{width:34px;height:34px;border-radius:11px}
.brand--compact .brand__mark .i{width:18px;height:18px}

.nav{display:grid;gap:4px}
.nav__link{
  display:flex;align-items:center;gap:12px;
  padding:11px 14px;
  border-radius:12px;
  color:#3D5A78;
  font-size:14.5px;
  font-weight:600;
  text-decoration:none;
  transition:background .15s,color .15s;
}
.nav__link .i{width:20px;height:20px;color:#7E97B3;stroke-width:1.8;transition:color .15s}
.nav__link.is-active{background:var(--blue-100);color:var(--blue-dark)}
.nav__link.is-active .i{color:var(--blue)}

.sidebar__foot{margin-top:auto;padding:12px 10px 0;border-top:1px solid var(--line)}
.sidebar__course{font-size:11.5px;font-weight:600;color:#41566D}
.sidebar__school{font-size:11px;color:var(--muted);margin-top:2px}

/* ---------- 5. Topbar ---------- */
.topbar{
  position:sticky;top:0;z-index:20;
  display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:10px 14px;
  padding-top:max(10px,env(safe-area-inset-top));
  background:rgba(242,246,251,.9);
  -webkit-backdrop-filter:blur(10px);
  backdrop-filter:blur(10px);
}
.iconbtn{
  display:grid;place-items:center;
  width:42px;height:42px;
  border:0;border-radius:12px;
  background:transparent;
  color:var(--ink);
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
.iconbtn:active{background:#E4EDF8}

/* ---------- 6. Vistas ---------- */
.view{display:none}
.view:target{display:block}
@supports selector(:has(*)){
  body:not(:has(.view:target)) #splash{display:block}
}

.page{
  display:grid;
  gap:16px;
  width:100%;
  max-width:880px;
  margin-inline:auto;
  padding:16px 16px calc(88px + env(safe-area-inset-bottom));
}
.page__head{display:grid;gap:2px}
.eyebrow{
  font-size:11px;font-weight:700;
  letter-spacing:.12em;text-transform:uppercase;
  color:var(--blue);
}
.page__title{
  font-size:clamp(24px,5.6vw,32px);
  line-height:1.14;
  letter-spacing:-.028em;
  font-weight:750;
  margin-top:4px;
}
.page__sub{margin-top:8px;font-size:14px;color:var(--muted);max-width:48ch}
.back{
  display:inline-flex;align-items:center;gap:6px;
  width:max-content;
  font-size:13px;font-weight:600;
  color:var(--muted);
  text-decoration:none;
  padding:4px 0;
}
.back .i{width:16px;height:16px}
.back:active{color:var(--blue)}

.muted{color:var(--muted)}
.note{font-size:12px;line-height:1.55;color:var(--muted)}
.link{
  display:inline-block;
  margin-top:14px;
  color:var(--blue);
  font-size:14px;
  font-weight:650;
  text-decoration:none;
}
.link:hover{text-decoration:underline}
.disclaimer{
  margin-top:16px;padding-top:14px;
  border-top:1px solid var(--line);
  font-size:11.5px;line-height:1.55;color:var(--muted);
}

/* ---------- 7. Botones ---------- */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  min-height:50px;
  padding:0 22px;
  border:0;border-radius:14px;
  font-size:15px;font-weight:700;
  text-decoration:none;
  cursor:pointer;
  touch-action:manipulation;
  transition:transform .15s var(--ease),filter .15s var(--ease),background .15s;
  -webkit-tap-highlight-color:transparent;
}
.btn:active{transform:scale(.985)}
.btn .i{width:18px;height:18px}
.btn--primary{background:var(--blue);color:#fff;box-shadow:0 14px 26px -16px rgba(26,95,174,.9)}
.btn--accent{background:var(--orange);color:#3A2000;box-shadow:0 14px 26px -16px rgba(120,70,0,.8)}
.btn--ghost{background:#fff;color:var(--ink);border:1.5px solid var(--line)}
.btn--outline-light{background:rgba(255,255,255,.1);color:#fff;border:1.5px solid rgba(255,255,255,.55)}
.btn--on-blue{background:#fff;color:var(--blue-dark)}
.btn--block{width:100%}

/* ---------- 8. Splash ---------- */
.view--splash{
  position:fixed;inset:0;z-index:80;
  background:
    radial-gradient(600px 420px at 50% 12%,rgba(255,255,255,.16),transparent 65%),
    linear-gradient(160deg,#1A5FAE 0%,#14508F 55%,#0F3A6B 100%);
  color:#fff;
}
.splash{
  display:flex;flex-direction:column;justify-content:space-between;
  min-height:100vh;min-height:100dvh;
  padding:calc(64px + env(safe-area-inset-top)) 26px calc(32px + env(safe-area-inset-bottom));
  text-align:center;
}
.splash__brand{display:grid;justify-items:center;gap:12px;margin-top:8vh}
.splash__mark{
  display:grid;place-items:center;
  width:96px;height:96px;
  border-radius:30px;
  background:rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.22);
  color:#fff;
  box-shadow:0 20px 50px -24px rgba(0,0,0,.6);
}
.splash__mark .i{width:48px;height:48px;stroke-width:1.6}
.splash__title{font-size:34px;font-weight:800;letter-spacing:-.03em}
.splash__sub{font-size:13px;letter-spacing:.06em;text-transform:uppercase;color:rgba(255,255,255,.72)}
.splash__foot{display:grid;justify-items:center;gap:16px}
.splash__foot .btn{min-width:200px}
.splash__note{font-size:11.5px;color:rgba(255,255,255,.6)}
.loader{width:150px;height:4px;border-radius:999px;background:rgba(255,255,255,.2);overflow:hidden}
.loader span{display:block;width:40%;height:100%;border-radius:999px;background:#fff;animation:slide 1.5s var(--ease) infinite}
@keyframes slide{0%{transform:translateX(-110%)}100%{transform:translateX(360%)}}

/* ---------- 9. Inicio ---------- */
.hero{
  position:relative;
  isolation:isolate;
  overflow:hidden;
  padding:26px 22px 24px;
  border-radius:24px;
  background:linear-gradient(140deg,#1A5FAE 0%,#2A73C4 55%,#4A93D8 100%);
  color:#fff;
  box-shadow:0 26px 46px -32px rgba(26,95,174,.95);
}
.hero__eyebrow{font-size:10.5px;font-weight:700;letter-spacing:.14em;text-transform:uppercase;color:#C3DBF6}
.hero__title{margin-top:8px;font-size:clamp(26px,6.6vw,36px);line-height:1.08;letter-spacing:-.03em;font-weight:800}
.hero__text{margin-top:10px;font-size:14px;line-height:1.55;color:rgba(255,255,255,.86);max-width:36ch}
.hero__actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:20px}
.hero__art{
  position:absolute;right:-30px;bottom:-36px;z-index:-1;
  width:200px;height:200px;
  color:#fff;opacity:.13;
  fill:none;stroke:currentColor;stroke-width:1.1;
}

.quick{display:grid;gap:10px}
.quick__card{
  display:flex;align-items:center;gap:12px;
  padding:13px 14px;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:16px;
  text-decoration:none;
  color:inherit;
  box-shadow:var(--shadow);
  transition:transform .15s var(--ease),background .15s;
}
.quick__card:active{transform:scale(.99);background:#FAFCFF}
.quick__icon{
  display:grid;place-items:center;
  width:44px;height:44px;flex:none;
  border-radius:13px;
  background:var(--blue-100);
  color:var(--blue);
}
.quick__icon .i{width:21px;height:21px}
.quick__icon--orange{background:var(--orange-soft);color:var(--orange-dark)}
.quick__text{display:grid;gap:1px;flex:1;min-width:0}
.quick__text strong{font-size:14.5px;font-weight:700}
.quick__text small{font-size:12px;color:var(--muted)}
.quick__chev{width:18px;height:18px;color:#A9BCD0}

.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:20px;
  box-shadow:var(--shadow);
}
.card__title{font-size:17px;font-weight:750;letter-spacing:-.015em;margin-bottom:6px}
.card--row{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:14px}
.card--row p{font-size:14px;line-height:1.5}
.card--row .btn{min-height:46px;flex:none}

.formula{
  margin-top:14px;
  padding:14px;
  border-radius:14px;
  background:var(--blue-50);
  border:1px dashed #C6DBEF;
  text-align:center;
  font-size:14.5px;
  font-weight:700;
  color:var(--blue-dark);
  font-variant-numeric:tabular-nums;
}

/* ---------- 10. Calculadora ---------- */
.calc{display:grid;gap:16px}
.calc__form{display:grid;gap:16px}
.field{display:grid;gap:7px;align-content:start}
.field__label{font-size:11.5px;font-weight:700;letter-spacing:.09em;text-transform:uppercase;color:var(--muted)}
.field__control{position:relative;display:flex;align-items:center}
.input{
  width:100%;
  height:56px;
  padding:0 56px 0 16px;
  border:1.5px solid var(--line);
  border-radius:14px;
  background:#fff;
  color:var(--ink);
  font:inherit;
  font-size:18px;
  font-weight:650;
  font-variant-numeric:tabular-nums;
}
.input::placeholder{color:#A9BCD0;font-weight:500}
.input:focus{outline:none;border-color:var(--blue);box-shadow:0 0 0 4px rgba(26,95,174,.12)}
.field__unit{position:absolute;right:16px;font-size:13px;font-weight:700;color:var(--muted);pointer-events:none}
.field__help{font-size:11.5px;color:var(--muted)}
.field__error{font-size:12px;font-weight:600;color:#C0362B}
.field.is-invalid .input{border-color:#D64545;box-shadow:0 0 0 4px rgba(214,69,69,.1)}
.calc__hint{font-size:11.5px;color:var(--muted);text-align:center}

.calc__aside{display:grid;gap:10px;align-content:start}
.preview__value{
  margin-top:6px;
  font-size:clamp(42px,11vw,58px);
  line-height:1;
  font-weight:800;
  letter-spacing:-.045em;
  color:var(--blue-dark);
  font-variant-numeric:tabular-nums;
}
.preview__value small{font-size:14px;font-weight:600;color:var(--muted);margin-left:6px;letter-spacing:0}
.preview__range{font-size:12.5px;line-height:1.5;color:var(--muted)}
.preview__range strong{color:var(--ink)}
.preview__empty{font-size:13.5px;color:var(--muted);line-height:1.55}

/* ---------- 11. Resultado ---------- */
.result{display:grid;gap:0;justify-items:start}
.result__value{
  font-size:clamp(54px,15vw,70px);
  line-height:1;
  font-weight:800;
  letter-spacing:-.05em;
  color:var(--blue-dark);
  font-variant-numeric:tabular-nums;
}
.result__value small{font-size:16px;font-weight:600;color:var(--muted);margin-left:8px;letter-spacing:0}
.result__range{margin-top:16px;font-size:13.5px;line-height:1.5;color:var(--muted);width:100%}
.result__range strong{color:var(--ink);font-weight:700}
.result__note{margin-top:10px;font-size:14px;line-height:1.6;color:#34495F;width:100%}
.result__actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:20px;width:100%}
.result__actions .btn{flex:1 1 150px}
.result .disclaimer{width:100%}

.badge{
  display:inline-flex;align-items:center;gap:8px;
  width:max-content;
  margin-top:14px;
  padding:8px 14px;
  border-radius:999px;
  font-size:13px;
  font-weight:700;
}
.badge::before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor;flex:none}
.badge--bajo{background:#E7F1FA;color:#1F6DAE}
.badge--saludable{background:#E4F5EC;color:#1F7A50}
.badge--sobrepeso{background:#FDF3D9;color:#8A6400}
.badge--ob1{background:#FCEBDD;color:#A44F16}
.badge--ob2{background:#FBE3D9;color:#A33A18}
.badge--ob3{background:#FADDD9;color:#8E1F16}

.gauge{display:grid;gap:6px;margin-top:16px;width:100%}
.gauge__bar{
  position:relative;
  height:12px;
  border-radius:999px;
  background:linear-gradient(90deg,
    #3E8ED0 0 24.3%,
    #2E9E6B 24.3% 42.9%,
    #E0A100 42.9% 57.1%,
    #E07B39 57.1% 71.4%,
    #D9542B 71.4% 85.7%,
    #B3261E 85.7% 100%);
}
.gauge__marker{
  position:absolute;top:50%;left:50%;
  width:20px;height:20px;
  margin-left:-10px;
  transform:translateY(-50%);
  border-radius:50%;
  background:#fff;
  border:3px solid var(--ink);
  box-shadow:0 2px 8px rgba(22,38,58,.28);
  transition:left .5s var(--ease);
}
.gauge__ends{display:flex;justify-content:space-between;font-size:10.5px;font-weight:600;color:var(--muted)}

.empty{display:grid;justify-items:center;gap:10px;text-align:center;padding:36px 20px}
.empty__icon{
  display:grid;place-items:center;
  width:66px;height:66px;
  border-radius:50%;
  background:var(--blue-50);
  color:var(--blue);
}
.empty__icon .i{width:28px;height:28px}
.empty__title{font-size:17px;font-weight:700}
.empty .btn{margin-top:6px}

/* ---------- 12. Clasificación ---------- */
.table{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:18px;
  overflow:hidden;
  box-shadow:var(--shadow);
}
.table__head,.table__row{
  display:grid;
  grid-template-columns:minmax(0,.95fr) minmax(0,1.05fr);
  gap:12px;
  align-items:center;
  padding:14px 16px;
}
.table__head{
  background:var(--blue-50);
  font-size:10.5px;
  font-weight:700;
  letter-spacing:.09em;
  text-transform:uppercase;
  color:var(--muted);
}
.table__row{border-top:1px solid var(--line);font-size:14px}
.table__range{color:#41566D;font-variant-numeric:tabular-nums}
.table__cat{display:flex;align-items:center;gap:8px;font-weight:600}
.table__row.is-current{background:#EFF7FF;box-shadow:inset 3px 0 0 var(--blue)}
.table__row.is-current .table__cat{color:var(--blue-dark)}
.dot{width:9px;height:9px;border-radius:50%;flex:none}
.dot--bajo{background:#3E8ED0}
.dot--saludable{background:#2E9E6B}
.dot--sobrepeso{background:#E0A100}
.dot--ob1{background:#E07B39}
.dot--ob2{background:#D9542B}
.dot--ob3{background:#B3261E}

/* ---------- 13. Consejos ---------- */
.tips{display:grid;gap:12px}
.tip{
  display:flex;gap:14px;
  padding:16px;
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
}
.tip__icon{
  display:grid;place-items:center;
  width:44px;height:44px;flex:none;
  border-radius:13px;
  background:var(--orange-soft);
  color:var(--orange-dark);
}
.tip__icon .i{width:22px;height:22px}
.tip__title{font-size:14.5px;font-weight:700;margin-bottom:4px}
.tip__text{font-size:13px;line-height:1.55;color:var(--muted)}

/* ---------- 14. Acerca de ---------- */
.about{display:grid;justify-items:center;text-align:center;gap:10px;padding:28px 20px}
.about__mark{
  display:grid;place-items:center;
  width:74px;height:74px;
  border-radius:23px;
  background:var(--blue);
  color:#fff;
  box-shadow:0 18px 34px -20px rgba(26,95,174,.9);
}
.about__mark .i{width:38px;height:38px;stroke-width:1.6}
.about__name{font-size:20px;font-weight:800;letter-spacing:-.02em;margin-top:2px}
.chip{
  display:inline-flex;align-items:center;
  padding:5px 12px;
  border-radius:999px;
  background:var(--blue-100);
  color:var(--blue-dark);
  font-size:11.5px;
  font-weight:700;
}
.about__text{font-size:13.5px;line-height:1.6;max-width:48ch}
.about__list{display:grid;gap:8px;width:100%;margin-top:10px;text-align:left}
.about__list div{display:grid;gap:2px;padding:10px 12px;background:var(--blue-50);border-radius:12px}
.about__list dt{font-size:10.5px;font-weight:700;letter-spacing:.09em;text-transform:uppercase;color:var(--muted)}
.about__list dd{font-size:13.5px;font-weight:600;color:var(--ink)}

/* ---------- 15. Barra inferior ---------- */
.tabbar{
  position:fixed;left:0;right:0;bottom:0;z-index:30;
  display:grid;grid-template-columns:repeat(4,1fr);
  padding:6px 8px calc(6px + env(safe-area-inset-bottom));
  background:rgba(255,255,255,.95);
  border-top:1px solid var(--line);
  -webkit-backdrop-filter:blur(12px);
  backdrop-filter:blur(12px);
}
.tab{
  display:grid;justify-items:center;gap:3px;
  padding:6px 0;
  border-radius:12px;
  font-size:10.5px;font-weight:600;
  color:var(--muted);
  text-decoration:none;
  -webkit-tap-highlight-color:transparent;
}
.tab .i{width:22px;height:22px}
.tab.is-active{color:var(--blue)}
.tab:active{background:var(--blue-50)}

/* ---------- 16. Scrim + toast ---------- */
.scrim{position:fixed;inset:0;z-index:45;background:rgba(10,32,58,.45);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}
body.is-locked{overflow:hidden}

.toast{
  position:fixed;left:50%;bottom:calc(96px + env(safe-area-inset-bottom));
  transform:translate(-50%,10px);
  z-index:90;
  max-width:calc(100% - 32px);
  padding:11px 18px;
  border-radius:999px;
  background:#12263C;
  color:#fff;
  font-size:12.5px;
  font-weight:600;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s var(--ease),transform .2s var(--ease);
}
.toast.is-on{opacity:1;transform:translate(-50%,0)}

/* ---------- 17. Responsive ---------- */
@media (min-width:560px){
  .quick{grid-template-columns:1fr 1fr}
}

@media (min-width:640px){
  .tips{grid-template-columns:1fr 1fr}
  .page{padding-inline:24px}
  .hero{padding:32px 28px 30px}
  .hero__art{width:240px;height:240px;right:-20px;bottom:-40px}
}

@media (min-width:900px){
  .shell{display:grid;grid-template-columns:264px minmax(0,1fr);align-items:start}

  .sidebar{
    position:sticky;top:0;
    width:auto;height:100vh;height:100dvh;
    transform:none;visibility:visible;
    z-index:auto;
    box-shadow:none;
    padding:22px 16px;
    gap:26px;
  }
  .sidebar__close{display:none}

  .topbar{display:none}
  .tabbar{display:none}
  .scrim{display:none !important}

  .page{padding:40px 36px 64px;gap:20px;max-width:860px}
  .page__title{font-size:32px}
  .hero__title{font-size:36px}

  .calc{grid-template-columns:minmax(0,1.05fr) minmax(0,.95fr);align-items:start}
  .calc__aside{position:sticky;top:24px}
  .result__actions .btn{flex:0 0 auto}
}

@media (min-width:1200px){
  .page{max-width:900px}
}

/* ---------- 18. Accesibilidad ---------- */
@media (hover:hover){
  .btn--primary:hover{filter:brightness(1.07)}
  .btn--accent:hover{filter:brightness(1.05)}
  .btn--ghost:hover{background:#F8FBFF}
  .nav__link:hover{background:var(--blue-50)}
  .quick__card:hover{background:#FBFDFF}
  .iconbtn:hover{background:#E9F1FA}
}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.001ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.001ms !important;
  }
  .loader span{width:100%;transform:none}
}
