/* PsaicoTools Recursos · carcasa común (modo página, modo sesión, compartido, impresión) */
:root {
  --papel: #FDFAF5;
  --papel-2: #F5EFE4;
  --tinta: #1D2A34;
  --cuerpo: #3E4C57;
  --nota: #5C6A73;
  --linea: #D9DEE1;
  --azul: #2F6394;
  --azul-claro: #EAF2FA;
  --rojo: #C6492F;
  --ambar: #B07316;
  --verde: #3E7A4D;
  --display: 'Fraunces', Georgia, serif;
  --texto: 'DM Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.r-page { padding-top: 64px; background: var(--papel); color: var(--tinta); font-family: var(--texto); font-size: 16px; line-height: 1.5; -webkit-tap-highlight-color: transparent; }
:where(.r-page) button { font: inherit; color: inherit; }
:where(.r-page) :focus-visible { outline: 2.5px solid var(--azul); outline-offset: 3px; border-radius: 4px; }
/* Barra de acciones dentro de la cabecera del recurso (en la web la navegación es la del sitio) */
.r-head .r-actions { margin: 10px 0 0; justify-content: flex-start; flex-wrap: wrap; }
body.session .r-site { display: none !important; }

/* ---------- barra superior ---------- */
.r-top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 16px; padding: 12px clamp(16px, 4vw, 40px); background: color-mix(in srgb, var(--papel) 92%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--linea); }
.r-brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--tinta); white-space: nowrap; }
.r-brand b { font-family: var(--display); font-weight: 500; font-size: 17px; }
.r-brand span { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--nota); }
.r-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.r-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px; border: 0; background: none; border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--cuerpo); }
.r-btn:hover { background: var(--papel-2); color: var(--tinta); }
.r-btn svg { width: 18px; height: 18px; flex: none; }
.r-btn.primary { background: var(--tinta); color: var(--papel); padding-inline: 16px; }
.r-btn.primary:hover { background: #2C3B46; color: #fff; }
.r-only-shared { display: none; }
body.shared .r-only-shared { display: inline-flex; }
body.shared .r-only-pro { display: none !important; }

/* ---------- cabecera del recurso ---------- */
.r-head { padding: clamp(20px, 4vw, 40px) clamp(16px, 4vw, 40px) 8px; max-width: 1180px; margin: 0 auto; display: grid; gap: 8px; }
.r-eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--nota); }
.r-title { margin: 0; font-family: var(--display); font-weight: 340; font-size: clamp(34px, 6vw, 56px); line-height: 1; letter-spacing: -.025em; text-wrap: balance; }
.r-title em { font-weight: 300; color: var(--azul); }
.r-lede { margin: 4px 0 0; max-width: 56ch; color: var(--cuerpo); font-size: 16px; }
.r-sharednote { display: none; margin-top: 6px; font-size: 13px; color: var(--nota); }
body.shared .r-sharednote { display: block; }

.r-stage { max-width: 1180px; margin: 0 auto; padding: 8px clamp(12px, 4vw, 40px) 40px; }

/* ---------- debajo del objeto (SEO / cómo se usa) ---------- */
.r-more { max-width: 1180px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 64px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px 40px; border-top: 1px solid var(--linea); }
.r-more h2 { font-family: var(--display); font-weight: 500; font-size: 19px; margin: 24px 0 6px; }
.r-more p { margin: 0; color: var(--cuerpo); font-size: 15px; max-width: 60ch; }

/* ---------- barra inferior móvil ---------- */
.r-bottombar { display: none; }
@media (max-width: 720px) {
  .r-actions .r-btn:not(.primary) { display: none; }
  .r-actions .r-btn.primary { min-height: 36px; font-size: 13px; padding-inline: 12px; }
  .r-bottombar { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); background: var(--papel); border-top: 1px solid var(--linea); }
  .r-bottombar .r-btn { flex-direction: column; gap: 2px; font-size: 11.5px; min-height: 52px; border-radius: 12px; justify-content: center; }
  .r-page { padding-bottom: 72px; }
  body.session .r-page { padding-bottom: 0; }
}

/* ---------- modo sesión ---------- */
.r-session-ui { display: none; }
body.session .r-top, body.session .r-head, body.session .r-more, body.session .r-bottombar { display: none; }
body.session .r-stage { max-width: none; min-height: 100%; padding: clamp(16px, 3vw, 32px); display: flex; flex-direction: column; justify-content: center; }
body.session .r-session-ui { display: flex; justify-content: flex-end; position: fixed; top: 0; left: 0; right: 0; z-index: 30; gap: 8px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; background: color-mix(in srgb, var(--papel) 94%, transparent); border-bottom: 1px solid var(--linea); }
/* La barra de sesión es una franja propia: el contenido empieza debajo y nunca queda tapado */
body.session .r-stage { padding-top: calc(72px + env(safe-area-inset-top, 0px)); }
body.session .r-session-ui .r-btn { background: var(--papel-2); min-height: 44px; }
body.session { --s: 1.18; }
html:has(body.session) { background: var(--papel); }
body.session .r-page { min-height: 100dvh; padding-top: 0; }
/* En sesión no se guarda: el ordenador de la consulta lo usan varias personas */
body.session [data-act="save"] { display: none !important; }
.r-guardado { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 18px; padding: 8px 8px 8px 16px; background: var(--azul-claro); border-radius: 12px; font-size: 14px; color: var(--cuerpo); }
.r-guardado span { margin-right: auto; }
body.session .r-guardado { display: none; }

/* ---------- hoja (diálogo) ---------- */
.r-sheet { border: 0; padding: 0; width: min(720px, 100vw - 24px); max-height: min(92vh, 100% - 24px); border-radius: 18px; background: var(--papel); color: var(--tinta); box-shadow: 0 30px 80px rgba(29, 42, 52, .28); }
.r-sheet::backdrop { background: rgba(29, 42, 52, .42); }
.r-sheet[open] { animation: sheet-in .32s var(--ease); }
@keyframes sheet-in { from { transform: translateY(16px); opacity: 0; } }
.r-sheet-in { padding: 22px clamp(18px, 4vw, 30px) 24px; display: grid; gap: 16px; }
.r-sheet h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 26px; }
.r-sheet p { margin: 0; color: var(--cuerpo); font-size: 15px; }
.r-sheet .r-x { position: absolute; top: 12px; right: 12px; }
.r-link { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: #fff; border: 1px solid var(--linea); border-radius: 10px; font-family: var(--mono); font-size: 12.5px; overflow-x: auto; white-space: nowrap; }
.r-link span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.r-row { display: flex; flex-wrap: wrap; gap: 8px; }
.r-small { font-size: 13px !important; color: var(--nota) !important; }
.r-preview { background: var(--papel-2); border-radius: 12px; padding: 16px; display: flex; justify-content: center; overflow: hidden; }
.r-preview .r-a4 { width: 100%; max-width: 420px; aspect-ratio: 210 / 297; background: #fff; box-shadow: 0 6px 24px rgba(29,42,52,.16); overflow: hidden; position: relative; }
.r-a4-inner { position: absolute; top: 0; left: 0; width: 794px; height: 1123px; transform-origin: 0 0; }
.r-toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; background: var(--tinta); color: var(--papel); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 60; transition: .3s var(--ease); pointer-events: none; }
.r-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- impresión ---------- */
#r-print { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; padding: 0 !important; }
  body > *:not(#r-print) { display: none !important; }
  #r-print { display: block; }
  #r-print .r-a4-inner { position: static; transform: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
