/* theme_habitos.css
   -----------------------------------------------------------------------
   Capa del módulo de hábitos sobre el tema compartido
   (budget app/theme_presupuesto.css). Los componentes .rv-* salen de allí;
   aquí solo se cambian los tokens de color y se añaden las piezas que no
   existen en finanzas: la tira de la semana, el botón de marcar, el anillo
   del día y el mural de constancia.

   La paleta conserva el terracota y los neutros cálidos del diseño
   original de Stitch, pero con la estructura de superficies de Revolut:
   página clara, tarjetas un tono por debajo y casi negro en modo oscuro.
   ----------------------------------------------------------------------- */

/* ----------------------------- Tokens: claro ----------------------------- */
:root {
    --color-background: 250 246 240;
    --color-surface: 250 246 240;
    --color-surface-bright: 255 255 255;
    --color-surface-dim: 236 229 220;
    --color-surface-container-lowest: 255 255 255;
    --color-surface-container-low: 246 241 234;
    --color-surface-container: 242 236 228;
    --color-surface-container-high: 235 228 219;
    --color-surface-container-highest: 227 219 209;
    --color-surface-variant: 232 225 216;

    --color-on-background: 42 34 29;
    --color-on-surface: 42 34 29;
    --color-on-surface-variant: 110 100 92;
    --color-inverse-surface: 42 34 29;
    --color-inverse-on-surface: 250 246 240;

    --color-outline: 158 148 138;
    --color-outline-variant: 226 218 208;

    /* Terracota del diseño original: el acento del módulo. */
    --color-primary: 194 101 42;
    --color-on-primary: 255 255 255;
    --color-primary-container: 251 232 216;
    --color-on-primary-container: 88 38 10;
    --color-primary-fixed: 251 232 216;
    --color-primary-fixed-dim: 240 168 120;
    --color-on-primary-fixed: 64 26 8;
    --color-on-primary-fixed-variant: 138 69 24;
    --color-inverse-primary: 240 168 120;
    --color-surface-tint: 194 101 42;

    --color-secondary: 120 112 106;
    --color-on-secondary: 255 255 255;
    --color-secondary-container: 234 226 218;
    --color-on-secondary-container: 96 88 80;

    /* Rojo tierra del diseño original, para los acentos secundarios. */
    --color-tertiary: 160 72 60;
    --color-on-tertiary: 255 255 255;
    --color-tertiary-container: 252 224 220;
    --color-on-tertiary-container: 90 30 24;

    /* Fondo de la tarjeta principal: "metal" cálido en vez del verde. */
    --hb-hero-from: #8a3f14;
    --hb-hero-mid: #3d1a08;
    --hb-hero-to: #160a04;
}

/* ----------------------------- Tokens: oscuro ----------------------------- */
html.dark {
    --color-background: 16 13 11;
    --color-surface: 16 13 11;
    --color-surface-bright: 46 40 36;
    --color-surface-dim: 10 8 7;
    --color-surface-container-lowest: 10 8 7;
    --color-surface-container-low: 25 21 18;
    --color-surface-container: 31 26 23;
    --color-surface-container-high: 40 34 30;
    --color-surface-container-highest: 52 45 40;
    --color-surface-variant: 52 45 40;

    --color-on-background: 248 243 238;
    --color-on-surface: 248 243 238;
    --color-on-surface-variant: 168 158 149;
    --color-inverse-surface: 248 243 238;
    --color-inverse-on-surface: 16 13 11;

    --color-outline: 122 112 104;
    --color-outline-variant: 52 45 40;

    --color-primary: 240 158 102;
    --color-on-primary: 52 22 4;
    --color-primary-container: 92 44 16;
    --color-on-primary-container: 255 220 196;
    --color-primary-fixed: 92 44 16;
    --color-primary-fixed-dim: 240 158 102;
    --color-on-primary-fixed: 255 220 196;
    --color-on-primary-fixed-variant: 255 196 160;
    --color-inverse-primary: 194 101 42;
    --color-surface-tint: 240 158 102;

    --color-secondary: 184 174 166;
    --color-on-secondary: 40 34 30;
    --color-secondary-container: 52 45 40;
    --color-on-secondary-container: 228 220 212;

    --color-tertiary: 236 150 136;
    --color-on-tertiary: 70 16 10;
    --color-tertiary-container: 80 30 24;
    --color-on-tertiary-container: 255 214 206;

    --hb-hero-from: #7a3810;
    --hb-hero-mid: #2e1406;
    --hb-hero-to: #0c0603;
}

/* --------------------------- Tarjeta del día --------------------------- */
/* Misma idea que .rv-paycard de finanzas, con el degradado terracota. */
.hb-hero {
    position: relative;
    overflow: hidden;
    border-radius: 26px;
    padding: 22px;
    color: #fff;
    background: radial-gradient(130% 120% at 88% 0%, var(--hb-hero-from) 0%, var(--hb-hero-mid) 46%, var(--hb-hero-to) 100%);
}

.hb-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(128deg, rgb(255 255 255 / .14) 0%, rgb(255 255 255 / 0) 46%);
}

.hb-hero>* {
    position: relative;
    z-index: 1;
}

.hb-hero__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: rgb(255 255 255 / .62);
}

.hb-hero__muted {
    color: rgb(255 255 255 / .72);
}

.hb-hero .rv-badge {
    background-color: rgb(255 255 255 / .14);
    color: #fff;
}

/* Botones sobre la tarjeta terracota (aviso del modo descanso en Ajustes). */
.hb-hero .rv-btn--primary {
    background-color: #fff;
    color: #58260a;
}

.hb-hero .rv-btn--ghost {
    color: #fff;
}

.hb-hero .rv-btn--ghost:hover {
    background-color: rgb(255 255 255 / .14);
}

/* Anillo de progreso: pista tenue y arco con el acento claro. */
.hb-ring {
    transform: rotate(-90deg);
}

.hb-ring circle {
    fill: none;
    stroke-linecap: round;
}

.hb-ring__track {
    stroke: rgb(255 255 255 / .16);
}

.hb-ring__bar {
    stroke: #ffc59c;
    transition: stroke-dashoffset .9s cubic-bezier(.2, .8, .2, 1);
}

/* ----------------------------- Tira semanal ----------------------------- */
.hb-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.hb-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 9px 0 10px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: rgb(var(--color-on-surface));
    font: inherit;
    cursor: pointer;
    transition: background-color .18s ease, transform .12s ease;
}

.hb-day:hover {
    background-color: rgb(var(--color-surface-container-high));
}

.hb-day:active {
    transform: scale(.95);
}

.hb-day__name {
    font-size: 12px;
    font-weight: 600;
    color: rgb(var(--color-on-surface-variant));
}

.hb-day__num {
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* Punto de estado del día: vacío, parcial o completo. */
.hb-day__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: rgb(var(--color-outline-variant));
}

.hb-day__dot--partial {
    background-color: rgb(var(--color-primary) / .45);
}

.hb-day__dot--full {
    background-color: rgb(var(--color-primary));
}

.hb-day__dot--none {
    background-color: transparent;
}

/* Día en modo descanso: una raya en vez de un punto. */
.hb-day__dot--rest {
    width: 10px;
    height: 2px;
    border-radius: 2px;
    background-color: rgb(var(--color-on-surface-variant) / .55);
}

.hb-day--today .hb-day__num {
    color: rgb(var(--color-primary));
}

.hb-day[aria-pressed="true"] {
    background-color: rgb(var(--color-on-surface));
    color: rgb(var(--color-surface));
}

.hb-day[aria-pressed="true"] .hb-day__name {
    color: rgb(var(--color-surface) / .7);
}

.hb-day[aria-pressed="true"] .hb-day__num {
    color: rgb(var(--color-surface));
}

/* El orden importa: la regla general del punto va antes que sus variantes. */
.hb-day[aria-pressed="true"] .hb-day__dot {
    background-color: rgb(var(--color-surface) / .35);
}

.hb-day[aria-pressed="true"] .hb-day__dot--partial {
    background-color: rgb(var(--color-primary-fixed-dim) / .6);
}

.hb-day[aria-pressed="true"] .hb-day__dot--full {
    background-color: rgb(var(--color-primary-fixed-dim));
}

.hb-day[aria-pressed="true"] .hb-day__dot--none {
    background-color: transparent;
}

.hb-day--future {
    opacity: .55;
}

/* ---------------------------- Fila de hábito ---------------------------- */
/* Botón redondo para marcar: vacío con borde, lleno con check. */
.hb-check {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 2px solid rgb(var(--color-outline) / .55);
    background: transparent;
    color: transparent;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .12s ease;
}

.hb-check .material-symbols-outlined {
    font-size: 24px;
    font-weight: 700;
}

.hb-check:hover {
    border-color: rgb(var(--color-primary));
    color: rgb(var(--color-primary) / .55);
}

.hb-check:active {
    transform: scale(.9);
}

.hb-check[aria-pressed="true"] {
    border-color: rgb(var(--color-primary));
    background-color: rgb(var(--color-primary));
    color: rgb(var(--color-on-primary));
}

.hb-check[disabled] {
    cursor: not-allowed;
    opacity: .4;
}

.hb-check[disabled]:hover {
    border-color: rgb(var(--color-outline) / .55);
    color: transparent;
}

/* El cuerpo de la fila abre el detalle del hábito: es un botón sin estilo
   propio para que se lea como el resto de la fila. */
.hb-row__open {
    align-self: stretch;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.hb-row__open:focus-visible,
.hb-check:focus-visible,
.hb-day:focus-visible,
.hb-option:focus-visible,
.hb-weekday:focus-visible {
    outline: 2px solid rgb(var(--color-primary));
    outline-offset: 2px;
}

/* En un móvil, con el temporizador y el check al lado, un nombre como
   "Fuerza y acondicionamiento" no cabe en una línea: se parte en dos
   antes que recortarse a media palabra. */
.hb-row .rv-row__title {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hb-row--done .rv-row__title {
    text-decoration: line-through;
    text-decoration-color: rgb(var(--color-on-surface-variant) / .6);
    color: rgb(var(--color-on-surface-variant));
}

/* Atajo al temporizador en las filas pendientes de hoy. */
.hb-row [data-timer] {
    color: rgb(var(--color-primary));
}

.hb-streak {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 700;
    color: rgb(var(--color-primary));
}

.hb-streak .material-symbols-outlined {
    font-size: 15px;
}

/* ----------------------------- Temporizador ----------------------------- */
.hb-timer {
    font-size: 64px;
    font-weight: 700;
    letter-spacing: -.04em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* --------------------------- Mural de constancia --------------------------- */
/* Con el ancho de una columna de escritorio las celdas serían enormes:
   el mural se queda en el tamaño de un calendario de bolsillo. */
.hb-heat {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    max-width: 420px;
    margin-inline: auto;
}

.hb-heat__head {
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    color: rgb(var(--color-on-surface-variant));
}

.hb-heat__cell {
    aspect-ratio: 1;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background-color: rgb(var(--color-surface-container-highest));
    color: rgb(var(--color-on-surface-variant));
}

.hb-heat__cell[data-level="1"] {
    background-color: rgb(var(--color-primary) / .22);
    color: rgb(var(--color-on-surface));
}

.hb-heat__cell[data-level="2"] {
    background-color: rgb(var(--color-primary) / .5);
    color: rgb(var(--color-on-surface));
}

.hb-heat__cell[data-level="3"] {
    background-color: rgb(var(--color-primary) / .78);
    color: rgb(var(--color-on-primary));
}

.hb-heat__cell[data-level="4"] {
    background-color: rgb(var(--color-primary));
    color: rgb(var(--color-on-primary));
}

/* Días sin hábitos programados o todavía por llegar. */
.hb-heat__cell--empty {
    background-color: rgb(var(--color-surface-container-high) / .6);
    color: rgb(var(--color-on-surface-variant) / .55);
}

.hb-heat__cell--today {
    box-shadow: 0 0 0 2px rgb(var(--color-surface-container)), 0 0 0 4px rgb(var(--color-on-surface));
}

.hb-heat__swatch {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    background-color: rgb(var(--color-surface-container-highest));
}

/* Mini barras de los últimos 7 días en el análisis por hábito. */
.hb-bars {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
    align-items: end;
}

.hb-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.hb-bar__fill {
    width: 100%;
    max-width: 22px;
    height: 34px;
    border-radius: 8px;
    background-color: rgb(var(--color-surface-container-highest));
}

.hb-bar__fill--done {
    background-color: rgb(var(--color-primary));
}

.hb-bar__fill--off {
    height: 8px;
    background-color: rgb(var(--color-surface-container-high));
}

.hb-bar__label {
    font-size: 11px;
    font-weight: 600;
    color: rgb(var(--color-on-surface-variant));
}

/* ------------------------------ Formulario ------------------------------ */
/* Píldoras de los días de la semana al crear un hábito. */
.hb-weekday {
    width: 100%;
    aspect-ratio: 1;
    max-width: 46px;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background-color: rgb(var(--color-surface-container-high));
    color: rgb(var(--color-on-surface-variant));
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease, transform .1s ease;
}

.hb-weekday:active {
    transform: scale(.92);
}

.hb-weekday[aria-pressed="true"] {
    background-color: rgb(var(--color-primary));
    color: rgb(var(--color-on-primary));
}

/* Tarjeta elegible (pilar, momento, dificultad). */
.hb-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border: 1px solid transparent;
    border-radius: 18px;
    background-color: rgb(var(--color-surface-container-high) / .7);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, transform .1s ease;
}

.hb-option:hover {
    background-color: rgb(var(--color-surface-container-high));
}

.hb-option:active {
    transform: scale(.98);
}

.hb-option[aria-pressed="true"] {
    border-color: rgb(var(--color-primary));
    background-color: rgb(var(--color-primary) / .1);
}

.hb-option--stack {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.hb-option--center {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 14px 6px;
}

.hb-option__check {
    margin-left: auto;
    font-size: 22px;
    color: rgb(var(--color-primary));
    opacity: 0;
    transition: opacity .15s ease;
}

.hb-option[aria-pressed="true"] .hb-option__check {
    opacity: 1;
}

.hb-option .rv-avatar {
    background-color: rgb(var(--color-surface-container-lowest));
    color: rgb(var(--color-on-surface-variant));
}

html.dark .hb-option .rv-avatar {
    background-color: rgb(var(--color-surface-container-highest));
}

.hb-option[aria-pressed="true"] .rv-avatar {
    background-color: rgb(var(--color-primary));
    color: rgb(var(--color-on-primary));
}

/* Hito (logro) bloqueado: se ve apagado hasta que se consigue. */
.hb-milestone--locked .rv-avatar {
    background-color: rgb(var(--color-surface-container-highest));
    color: rgb(var(--color-on-surface-variant));
}
