/* =========================================================
   OBJETIVOS DIARIOS — widget con 3 diseños
   Alargada (tall) · Aplastada (flat) · Rayas (stripes)
   Solo se animan transform y opacity para ir siempre fluido.
========================================================= */

.hb-root {
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hb-root[hidden] {
    display: none !important;
}

/* ---------- Barra superior ---------- */

.hb-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 14px;
    margin-bottom: 14px;
}

/* Estado de sincronización */

.hb-sync {
    display: flex;
    flex: 1 1 260px;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    min-width: 0;
    color: var(--muted);
    font-size: 13px;
}

.hb-sync[data-state="synced"] {
    color: var(--accent);
}

.hb-sync[data-state="local"],
.hb-sync[data-state="error"] {
    color: #ffd666;
}

.hb-sync__retry {
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.hb-sync__retry:hover {
    border-color: #3b424c;
}

.hb-sync__retry:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Carga y estado vacío */

.hb-loading {
    padding: 18px 0;
    color: var(--muted);
    font-size: 14px;
}

.hb-empty {
    display: flex;
    flex: 1 1 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 26px;
    background: rgba(255, 255, 255, 0.02);
    border: 2px dashed var(--border);
    border-radius: 18px;
}

.hb-empty strong {
    font-size: 18px;
    letter-spacing: -0.4px;
}

.hb-empty p {
    max-width: 520px;
    color: var(--muted);
    font-size: 14px;
}

.hb-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    margin-top: 6px;
    padding: 12px 18px;
    background: var(--accent);
    color: #090b0d;
    border: 1px solid rgba(184, 255, 61, 0.8);
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(184, 255, 61, 0.08);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease;
}

.hb-cta:hover {
    transform: translateY(-1px);
    background: #c3f65a;
}

.hb-cta:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.hb-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.hb-tool:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.04);
    border-color: #3b424c;
}

.hb-tool:active {
    transform: translateY(0);
}

/* ---------- Lista ---------- */

.hb-list {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px;
}

/* ---------- Tarjeta base ---------- */

.hb-card {
    --h: 80;
    position: relative;
    display: flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.hb-card.is-complete {
    border-color: hsl(var(--h) 70% 38%);
    box-shadow: 0 10px 34px hsl(var(--h) 90% 50% / 0.12);
}

.hb-shine {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: inherit;
    pointer-events: none;
}

.hb-shine::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 50%;
    background: linear-gradient(100deg, transparent, hsl(var(--h) 100% 80% / 0.22), transparent);
    transform: translateX(0) skewX(-18deg);
    opacity: 0;
}

.hb-card.is-celebrating .hb-shine::before {
    animation: hb-shine 1s var(--ease-out);
}

.hb-card.is-celebrating {
    animation: hb-glow 1s var(--ease-out);
}

@keyframes hb-shine {
    0% { transform: translateX(0) skewX(-18deg); opacity: 1; }
    100% { transform: translateX(380%) skewX(-18deg); opacity: 1; }
}

@keyframes hb-glow {
    0% { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
    30% { box-shadow: 0 0 0 3px hsl(var(--h) 90% 60% / 0.55), 0 0 44px hsl(var(--h) 100% 60% / 0.4); }
    100% { box-shadow: 0 10px 34px hsl(var(--h) 90% 50% / 0.12); }
}

.hb-icon {
    line-height: 1;
}

.hb-title {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: -0.4px;
}

.hb-gear {
    flex: none;
    padding: 4px 7px;
    background: transparent;
    color: var(--muted);
    border-radius: 8px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, transform 0.3s var(--ease-out);
}

.hb-gear:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
    transform: rotate(60deg);
}

/* ---------- Estadísticas y número que rueda ---------- */

.hb-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    color: var(--muted);
    font-size: 13px;
}

.hb-stat strong {
    color: hsl(var(--h) 90% 66%);
    font-weight: 800;
}

.hb-roll {
    display: inline-grid;
    overflow: hidden;
    vertical-align: bottom;
}

.hb-roll > span {
    grid-area: 1 / 1;
    display: block;
}

.hb-fire {
    padding: 2px 9px;
    background: hsl(var(--h) 60% 18%);
    color: hsl(var(--h) 90% 76%);
    border-radius: 99px;
    font-size: 12px;
    font-weight: 800;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.45s var(--ease-spring), opacity 0.25s ease;
}

.hb-fire.is-on {
    transform: scale(1);
    opacity: 1;
}

/* ---------- Casillas (cuadrados y rayas) ---------- */

.hb-cells {
    display: grid;
}

.hb-cell,
.hb-stripe {
    --s: 0;
    position: relative;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.hb-cell {
    aspect-ratio: 1;
    background: var(--surface-light);
    border-radius: 7px;
    transition: background-color 0.35s ease, box-shadow 0.45s ease, transform 0.2s var(--ease-out);
}

.hb-cell:hover {
    transform: scale(1.14);
}

.hb-cell.is-done {
    background: hsl(var(--h) 90% calc(38% + var(--s) * 2.4%));
    box-shadow: 0 0 calc(var(--s) * 1.3px) hsl(var(--h) 100% 60% / 0.5);
}

.hb-cell:focus-visible,
.hb-stripe:focus-visible,
.hb-btn:focus-visible,
.hb-gear:focus-visible,
.hb-tool:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

/* Invitación a marcar el día de hoy */
.hb-cell.is-today::after,
.hb-stripe.is-today::after {
    content: '';
    position: absolute;
    inset: -3px;
    border: 2px solid hsl(var(--h) 90% 72%);
    border-radius: inherit;
    pointer-events: none;
}

.hb-cell.is-today:not(.is-done)::after,
.hb-stripe.is-today:not(.is-done)::after {
    animation: hb-invite 2.4s ease-in-out infinite;
}

@keyframes hb-invite {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.25); opacity: 0.15; }
}

.hb-ring {
    position: absolute;
    inset: 0;
    border: 2px solid hsl(var(--h) 100% 72%);
    border-radius: inherit;
    pointer-events: none;
}

/* ---------- Botón principal ---------- */

.hb-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    overflow: hidden;
    isolation: isolate;
    background: var(--surface-light);
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 800;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: color 0.3s ease 0.1s, border-color 0.3s ease, transform 0.18s var(--ease-out);
    -webkit-tap-highlight-color: transparent;
}

.hb-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: hsl(var(--h) 90% 62%);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.55s var(--ease-out);
}

.hb-btn.is-done {
    color: #090b0d;
    border-color: transparent;
}

.hb-btn.is-done::before {
    transform: scaleX(1);
}

.hb-btn:hover:not(.is-done) {
    border-color: hsl(var(--h) 70% 50%);
}

.hb-btn:active {
    transform: scale(0.96);
}

.hb-check {
    flex: none;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hb-check path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    transition: stroke-dashoffset 0.45s var(--ease-out) 0.12s;
}

.hb-btn.is-done .hb-check path {
    stroke-dashoffset: 0;
}

.hb-check-wrap {
    display: grid;
    place-items: center;
    flex: none;
    width: 30px;
    height: 30px;
    border: 2px solid currentColor;
    border-radius: 50%;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.hb-check-wrap .hb-check {
    width: 18px;
    height: 18px;
}

.hb-btn.is-done .hb-check-wrap {
    background: #090b0d;
    border-color: #090b0d;
    color: hsl(var(--h) 90% 62%);
}

/* =========================
   DISEÑO 1 — ALARGADA
========================= */

.hb-card--tall {
    flex: 0 0 300px;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

.hb-card--tall .hb-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hb-card--tall .hb-icon {
    font-size: 22px;
}

.hb-card--tall .hb-title {
    flex: 1;
    min-width: 0;
    font-size: 20px;
}

.hb-card--tall .hb-cells {
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}

.hb-card--tall .hb-btn {
    width: 100%;
    min-height: 56px;
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 17px;
}

/* =========================
   DISEÑO 2 — APLASTADA
========================= */

.hb-card--flat {
    flex: 1 1 100%;
    align-items: center;
    gap: 22px;
    padding: 14px 18px;
}

.hb-card--flat .hb-info {
    display: flex;
    flex: 0 0 210px;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.hb-card--flat .hb-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hb-card--flat .hb-icon {
    font-size: 20px;
}

.hb-card--flat .hb-title {
    flex: 1;
    min-width: 0;
    font-size: 17px;
}

.hb-card--flat .hb-cells {
    flex: 1;
    min-width: 0;
    grid-template-columns: repeat(28, 1fr);
    gap: 4px;
}

.hb-card--flat .hb-cell {
    border-radius: 5px;
}

.hb-card--flat .hb-btn {
    flex: none;
    width: 54px;
    height: 54px;
    border-radius: 50%;
}

.hb-card--flat .hb-btn::before {
    transform: scale(0);
    transform-origin: center;
    border-radius: 50%;
}

.hb-card--flat .hb-btn.is-done::before {
    transform: scale(1.05);
}

.hb-card--flat .hb-check {
    width: 26px;
    height: 26px;
}

/* =========================
   DISEÑO 3 — RAYAS
========================= */

.hb-card--stripes {
    flex: 0 1 310px;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 14px;
}

.hb-card--stripes .hb-btn {
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
}

.hb-card--stripes .hb-btn::before {
    transform: scale(0);
    transform-origin: center;
    border-radius: 50%;
}

.hb-card--stripes .hb-btn.is-done::before {
    transform: scale(1.05);
}

.hb-card--stripes .hb-check {
    width: 20px;
    height: 20px;
}

.hb-card--stripes .hb-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.hb-card--stripes .hb-head {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hb-card--stripes .hb-icon {
    font-size: 13px;
}

.hb-card--stripes .hb-title {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-weight: 700;
}

.hb-card--stripes .hb-stats {
    flex: none;
    gap: 0;
    font-size: 12px;
}

.hb-card--stripes .hb-gear {
    padding: 2px 4px;
    font-size: 13px;
}

.hb-card--stripes .hb-cells {
    grid-template-columns: repeat(30, 1fr);
    gap: 3px;
    height: 26px;
}

.hb-stripe {
    height: 100%;
    background: transparent;
    border-radius: 3px;
}

.hb-stripe::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--surface-light);
    border-radius: 3px;
    transform: scaleY(0.34);
    transform-origin: bottom;
    transition: transform 0.5s var(--ease-spring), background-color 0.35s ease, box-shadow 0.45s ease;
}

.hb-stripe:hover::before {
    transform: scaleY(0.52);
}

.hb-stripe.is-done::before {
    background: hsl(var(--h) 90% calc(40% + var(--s) * 2.2%));
    box-shadow: 0 0 calc(var(--s) * 1.1px) hsl(var(--h) 100% 60% / 0.55);
    transform: scaleY(1);
}

.hb-stripe.is-today::after {
    inset: -2px -1px;
}

/* ---------- Añadir ---------- */

.hb-add {
    flex: 0 0 auto;
    align-self: stretch;
    min-width: 120px;
    padding: 14px 20px;
    background: transparent;
    color: var(--muted);
    border: 2px dashed var(--border);
    border-radius: 18px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s var(--ease-out);
}

.hb-add:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.hb-add:active {
    transform: scale(0.97);
}

/* ---------- Diálogo de personalización ---------- */

.hb-dialog {
    inset: 0;
    margin: auto;
    width: min(420px, 94vw);
    padding: 26px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.hb-dialog::backdrop {
    background: rgba(0, 0, 0, 0.66);
}

.hb-dialog[open] {
    animation: hb-dialog-in 0.35s var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
}

@keyframes hb-dialog-in {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

.hb-dialog h3 {
    margin-bottom: 4px;
    font-size: 20px;
    letter-spacing: -0.5px;
}

.hb-dialog label,
.hb-dialog .hb-label {
    display: block;
    margin: 14px 0 6px;
    color: var(--muted);
    font-size: 13px;
}

.hb-dialog input[type="text"] {
    width: 100%;
    padding: 11px 12px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.hb-dialog input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.hb-hue {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    border-radius: 6px;
    background: linear-gradient(90deg,
        hsl(0 80% 55%), hsl(60 80% 55%), hsl(120 80% 55%),
        hsl(180 80% 55%), hsl(240 80% 60%), hsl(300 80% 60%), hsl(360 80% 55%));
}

.hb-designs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.hb-design {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 0 !important;
    padding: 12px 6px 10px;
    background: var(--bg);
    color: var(--muted) !important;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 12px !important;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s var(--ease-out);
}

.hb-design:hover {
    transform: translateY(-2px);
}

.hb-design input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.hb-design:has(input:checked) {
    border-color: var(--accent);
    color: var(--text) !important;
}

.hb-design:has(input:focus-visible) {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

.hb-prev {
    display: grid;
    gap: 2px;
    width: 64px;
    height: 46px;
    padding: 5px;
    background: var(--surface-light);
    border-radius: 7px;
}

.hb-prev span {
    background: hsl(80 90% 55% / 0.85);
    border-radius: 1.5px;
}

.hb-prev span:nth-child(3n) {
    background: hsl(0 0% 100% / 0.12);
}

.hb-prev--tall {
    grid-template-columns: repeat(6, 1fr);
    height: 54px;
    width: 46px;
}

.hb-prev--flat {
    grid-template-columns: repeat(12, 1fr);
    align-content: center;
    height: 26px;
}

.hb-prev--flat span {
    height: 10px;
}

.hb-prev--stripes {
    grid-template-columns: repeat(12, 1fr);
    align-items: end;
    height: 30px;
}

.hb-prev--stripes span {
    height: 100%;
}

.hb-prev--stripes span:nth-child(3n) {
    height: 38%;
}

.hb-check-row {
    display: flex !important;
    align-items: flex-start;
    gap: 10px;
    margin-top: 16px !important;
    color: var(--text) !important;
    font-size: 14px !important;
    cursor: pointer;
}

.hb-check-row input {
    flex: none;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--accent);
}

.hb-check-row small {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.hb-dialog-actions {
    display: flex;
    gap: 8px;
    margin-top: 22px;
}

.hb-dialog-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

/* El atributo hidden debe ganar a display: inline-flex (p. ej. «Borrar» al crear un objetivo) */
.hb-dialog [hidden],
.hb-root [hidden] {
    display: none !important;
}

.hb-dialog-actions button:hover {
    transform: translateY(-1px);
}

.hb-dialog-actions .hb-save {
    flex: 1;
    background: var(--accent);
    color: #090b0d;
    border: 1px solid rgba(184, 255, 61, 0.8);
    box-shadow: 0 4px 10px rgba(184, 255, 61, 0.08);
}

.hb-dialog-actions .hb-save:hover {
    background: #c3f65a;
}

.hb-dialog-actions .hb-cancel {
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.hb-dialog-actions .hb-cancel:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: #3b424c;
}

.hb-dialog-actions .hb-delete {
    background: rgba(255, 107, 107, 0.07);
    color: #ffb4b4;
    border: 1px solid rgba(255, 107, 107, 0.28);
}

.hb-dialog-actions .hb-delete:hover {
    background: rgba(255, 107, 107, 0.12);
    border-color: rgba(255, 107, 107, 0.4);
}

.hb-dialog-actions button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Aviso y confeti ---------- */

.hb-toast {
    position: fixed;
    left: 50%;
    bottom: 80px;
    z-index: 90;
    max-width: calc(100vw - 32px);
    padding: 12px 22px;
    background: var(--accent);
    color: #090b0d;
    border-radius: 99px;
    font-weight: 800;
    text-align: center;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
    transform: translate(-50%, 30px) scale(0.9);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.5s var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)), opacity 0.25s ease;
}

.hb-toast.is-visible {
    transform: translate(-50%, 0) scale(1);
    opacity: 1;
}

.hb-fx {
    position: fixed;
    inset: 0;
    z-index: 95;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ---------- Transición entre diseños (View Transitions) ---------- */

::view-transition-group(*) {
    animation-duration: 0.5s;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Responsive ---------- */

@media (max-width: 700px) {
    .hb-card--tall,
    .hb-card--stripes {
        flex: 1 1 100%;
    }

    .hb-card--flat {
        flex-wrap: wrap;
        gap: 12px 14px;
    }

    .hb-card--flat .hb-info {
        flex: 1 1 calc(100% - 70px);
    }

    .hb-card--flat .hb-cells {
        order: 3;
        flex: 1 1 100%;
        grid-template-columns: repeat(14, 1fr);
    }

    .hb-card--flat .hb-cell:nth-child(-n + 14) {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hb-card.is-celebrating,
    .hb-card.is-celebrating .hb-shine::before,
    .hb-cell.is-today:not(.is-done)::after,
    .hb-stripe.is-today:not(.is-done)::after,
    .hb-dialog[open] {
        animation: none;
    }

    .hb-btn::before,
    .hb-check path,
    .hb-stripe::before,
    .hb-fire,
    .hb-toast {
        transition-duration: 0.01s;
        transition-delay: 0s;
    }
}
