/* ════════════════════════════════════════════════════════════════
   Reloj flip 3D retro — templates/partials/flip_clock.html
   Paletas negras con números blancos, eje y soporte cromados, AM/PM.

   Todo se mide en `cqi` (1 % del ancho del contenedor .fc), así el reloj
   escala con su columna sin desbordar: de ~280 px en móvil a 32rem.
   La caída: la hoja superior gira 0 → −90° sobre la bisagra y después la
   inferior 90° → 0. Sin movimiento (prefers-reduced-motion) no hay caída.
   ════════════════════════════════════════════════════════════════ */

.fc {
    --fc-duracion: 280ms;
    --fc-paleta-arriba: linear-gradient(180deg, #34363a 0%, #1f2023 100%);
    --fc-paleta-abajo: linear-gradient(180deg, #17181a 0%, #26282b 100%);
    --fc-numero: #f7f7f5;
    --fc-cromo: linear-gradient(180deg, #ffffff 0%, #d4d8dc 22%, #8e959c 50%, #eef0f2 72%, #9da3a9 100%);
    --fc-cromo-vertical: linear-gradient(90deg, #9da3a9 0%, #eef0f2 30%, #8e959c 55%, #d4d8dc 78%, #ffffff 100%);
    --fc-escena: radial-gradient(120% 90% at 50% 15%, #ffffff 0%, #eef1f4 55%, #e2e6ea 100%);
    --fc-escena-borde: #e5e7eb;
    --fc-pie: #4a5565;

    container-type: inline-size;
    width: 100%;
    max-width: 32rem;
    margin: 0 auto;
}

.dark .fc {
    --fc-escena: radial-gradient(120% 90% at 50% 15%, #1e2939 0%, #101828 60%, #0b1220 100%);
    --fc-escena-borde: #1e2939;
    --fc-pie: #99a1af;
}

.fc-escena {
    position: relative;
    padding: 7cqi 4cqi 6cqi;
    border: 1px solid var(--fc-escena-borde);
    border-radius: 1rem;
    background: var(--fc-escena);
    box-shadow: 0 20px 24px -4px rgba(16, 24, 40, .08), 0 8px 8px -4px rgba(16, 24, 40, .03);
}

/* ── Estructura: dos paneles sobre un eje, y el soporte debajo ── */
.fc-reloj {
    position: relative;
    display: flex;
    justify-content: center;
    gap: 3.5cqi;
    padding: 0 6cqi 13cqi;
}

/* Eje cromado: pasa por la bisagra de los dos paneles y asoma a los lados */
.fc-eje {
    position: absolute;
    top: 21cqi;
    left: 2cqi;
    right: 2cqi;
    height: 2.6cqi;
    transform: translateY(-50%);
    z-index: 2;
    border-radius: 999px;
    background: var(--fc-cromo);
    box-shadow: 0 .6cqi 1cqi rgba(0, 0, 0, .25);
}
.fc-eje::before,
.fc-eje::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 4.6cqi;
    height: 4.6cqi;
    transform: translateY(-50%);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffffff 0%, #d4d8dc 35%, #7f868d 75%, #5d636a 100%);
    box-shadow: 0 .4cqi .8cqi rgba(0, 0, 0, .3);
}
.fc-eje::before { left: -1cqi; }
.fc-eje::after { right: -1cqi; }

/* Soporte: dos postes desde los extremos del eje hasta una base cromada */
.fc-soporte {
    position: absolute;
    left: 1cqi;
    right: 1cqi;
    z-index: 1;
    bottom: 3cqi;
    height: 2.4cqi;
    border-radius: 999px;
    background: var(--fc-cromo);
    box-shadow: 0 1.6cqi 2.4cqi -1cqi rgba(0, 0, 0, .35);
}
.fc-soporte::before,
.fc-soporte::after {
    content: "";
    position: absolute;
    bottom: 100%;
    width: 1.8cqi;
    height: 29cqi;   /* de la base (≈49.6cqi) al eje (21cqi) */
    background: var(--fc-cromo-vertical);
}
.fc-soporte::before { left: 2.4cqi; }
.fc-soporte::after { right: 2.4cqi; }

/* ── Panel (marco negro) ── */
.fc-panel {
    position: relative;
    z-index: 3;
    flex: 0 0 38cqi;
    height: 42cqi;
    padding: 1.4cqi;
    border-radius: 2.6cqi;
    background: linear-gradient(180deg, #2a2c30 0%, #0d0e10 100%);
    box-shadow:
        inset 0 .3cqi 0 rgba(255, 255, 255, .08),
        0 2cqi 3cqi -1cqi rgba(0, 0, 0, .45);
}

/* ── Paleta ── */
.fc-paleta {
    position: relative;
    width: 100%;
    height: 100%;
    perspective: 140cqi;
    font-family: "Outfit", "Inter", system-ui, sans-serif;
    font-weight: 700;
    font-size: 22cqi;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.04em;
    color: var(--fc-numero);
}

/* Ranura de la bisagra */
.fc-paleta::after {
    content: "";
    position: absolute;
    z-index: 5;
    top: 50%;
    left: 0;
    right: 0;
    height: .55cqi;
    transform: translateY(-50%);
    background: #050505;
    box-shadow: 0 .2cqi 0 rgba(255, 255, 255, .06);
}

.fc-mitad,
.fc-hoja {
    position: absolute;
    left: 0;
    right: 0;
    height: 50%;
    overflow: hidden;
    backface-visibility: hidden;
}
.fc-sup,
.fc-hoja-sup {
    top: 0;
    border-radius: 1.6cqi 1.6cqi 0 0;
    background: var(--fc-paleta-arriba);
}
.fc-inf,
.fc-hoja-inf {
    bottom: 0;
    border-radius: 0 0 1.6cqi 1.6cqi;
    background: var(--fc-paleta-abajo);
}

/* El número ocupa la paleta entera; cada mitad muestra la suya */
.fc-mitad span,
.fc-hoja span {
    position: absolute;
    left: 0;
    right: 0;
    height: 200%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 .4cqi .8cqi rgba(0, 0, 0, .5);
}
.fc-sup span,
.fc-hoja-sup span { top: 0; }
.fc-inf span,
.fc-hoja-inf span { bottom: 0; }

/* Hojas: solo se ven mientras cae la paleta */
.fc-hoja {
    z-index: 3;
    visibility: hidden;
}
.fc-hoja-sup { transform-origin: 50% 100%; }
.fc-hoja-inf { transform-origin: 50% 0; transform: rotateX(90deg); }

.fc-cayendo .fc-hoja { visibility: visible; }
.fc-cayendo .fc-hoja-sup { animation: fc-cae-arriba var(--fc-duracion) ease-in forwards; }
.fc-cayendo .fc-hoja-inf { animation: fc-cae-abajo var(--fc-duracion) ease-out var(--fc-duracion) forwards; }
/* Sombra sobre la mitad de abajo mientras la hoja la tapa */
.fc-cayendo .fc-inf::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    animation: fc-sombra calc(var(--fc-duracion) * 2) ease-out forwards;
}

@keyframes fc-cae-arriba {
    from { transform: rotateX(0deg); filter: brightness(1); }
    to { transform: rotateX(-90deg); filter: brightness(.55); }
}
@keyframes fc-cae-abajo {
    from { transform: rotateX(90deg); filter: brightness(1.35); }
    to { transform: rotateX(0deg); filter: brightness(1); }
}
@keyframes fc-sombra {
    from { opacity: 0; }
    50% { opacity: 1; }
    to { opacity: 0; }
}

/* ── AM / PM ── */
.fc-ampm {
    position: absolute;
    z-index: 6;
    left: 3.4cqi;
    bottom: 2.6cqi;
    display: flex;
    flex-direction: column;
    gap: .4cqi;
    font-family: "Outfit", "Inter", system-ui, sans-serif;
    font-size: 2.6cqi;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .08em;
    color: #5f646b;
}
.fc-ampm .fc-activo { color: #ffffff; }

/* ── Pie ── */
.fc-pie {
    margin-top: .75rem;
    text-align: end;   /* a la izquierda va la tarjeta flotante de la landing */
    font-size: .875rem;
    color: var(--fc-pie);
}
.fc-pie-zona { display: inline-flex; align-items: center; gap: .35rem; }
.fc-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ── Desorden al pasar el mouse (flip-clock.js pone .fc-desorden y las variables) ──
   Los paneles se sueltan y giran en 3D, el eje se tuerce y las paletas caen rápido
   con números al azar. Al salir, vuelven a su sitio con un pequeño rebote. */
.fc-reloj { perspective: 160cqi; }
.fc-panel,
.fc-eje,
.fc-soporte {
    transition: transform .7s cubic-bezier(.34, 1.56, .64, 1);
}
.fc-escena { transition: box-shadow .4s ease; }
.fc-desorden { --fc-duracion: 90ms; }
.fc-desorden .fc-escena {
    box-shadow: 0 32px 48px -12px rgba(16, 24, 40, .22), 0 12px 16px -8px rgba(16, 24, 40, .08);
}
.fc-desorden .fc-panel {
    transform:
        translate3d(var(--fc-dx, 0), var(--fc-dy, 0), 0)
        rotateX(var(--fc-rx, 0deg)) rotateY(var(--fc-ry, 0deg)) rotateZ(var(--fc-rz, 0deg));
    transition: transform .45s cubic-bezier(.22, 1, .36, 1);
}
.fc-desorden .fc-eje {
    transform: translateY(-50%) rotate(var(--fc-eje-rz, 0deg));
    transition: transform .45s cubic-bezier(.22, 1, .36, 1);
}
.fc-desorden .fc-soporte {
    transform: rotate(calc(var(--fc-eje-rz, 0deg) * -.4));
    transition: transform .45s cubic-bezier(.22, 1, .36, 1);
}

/* ── Sin movimiento: el número cambia sin caída ni desorden ── */
@media (prefers-reduced-motion: reduce) {
    .fc-cayendo .fc-hoja { visibility: hidden; animation: none; }
    .fc-cayendo .fc-inf::after { animation: none; opacity: 0; }
    .fc-panel,
    .fc-eje,
    .fc-soporte { transition: none; }
}
