/* ═══════════════════════════════════════════════════════════════
   HOME WIDGETS — All dashboard widget styles
   ═══════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────
   W1. IDENTITY — Name, handle, status
   ─────────────────────────────────────────────────────────────── */
.w-identity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: 100%;
}

.w-identity__info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.w-identity__name {
    font-family: var(--rv-font-display);
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 900;
    color: var(--rv-fg);
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin: 0;
}

.w-identity__handle {
    font-family: var(--rv-font-mono);
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--rv-fg-dim);
    letter-spacing: 0.06em;
    margin: 0;
}

.w-identity__cursor {
    animation: cursorBlink 1s step-end infinite;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.w-identity__role {
    font-family: var(--rv-font-mono);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.04em;
}

.w-identity__status {
    font-family: var(--rv-font-mono);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.w-identity__status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00ff66;
    box-shadow: 0 0 6px #00ff66;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px #00ff66; }
    50% { opacity: 0.5; box-shadow: 0 0 12px #00ff66, 0 0 24px rgba(0, 255, 102, 0.3); }
}

[data-widget="identity"] {
    border-left: 2px solid var(--rv-accent);
}

/* ───────────────────────────────────────────────────────────────
   W2. CLOCK — Live time + date
   ─────────────────────────────────────────────────────────────── */
.w-clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 0.3rem;
}

.w-clock__time {
    font-family: var(--rv-font-mono);
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    font-weight: 500;
    color: var(--rv-fg);
    letter-spacing: 0.08em;
    line-height: 1;
}

.w-clock__colon {
    animation: colonBlink 1s step-end infinite;
}

@keyframes colonBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

.w-clock__date {
    font-family: var(--rv-font-pixel);
    font-size: 0.55rem;
    color: var(--rv-fg-dim);
    letter-spacing: 0.12em;
}

/* ───────────────────────────────────────────────────────────────
   W3. COORDINATES — Location readout
   ─────────────────────────────────────────────────────────────── */
.w-coords {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 0.2rem;
    position: relative;
}

.w-coords__lat,
.w-coords__lon {
    font-family: var(--rv-font-mono);
    font-size: 0.8rem;
    color: var(--rv-fg-dim);
    letter-spacing: 0.06em;
}

.w-coords__compass {
    position: absolute;
    top: 0.3rem;
    right: 0.3rem;
    width: 32px;
    height: 32px;
}

.w-coords__compass-svg {
    width: 100%;
    height: 100%;
}

.w-coords__needle {
    transform-origin: 20px 20px;
    animation: compassSpin 20s linear infinite;
}

@keyframes compassSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ───────────────────────────────────────────────────────────────
   W4. MARKET — Stocks + Crypto + Portfolio (4x3 centerpiece)
   ─────────────────────────────────────────────────────────────── */
[data-widget="market"] {
    padding: 0.5rem 0.65rem;
}

.w-market {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    gap: 0;
}

/* ─── Top: Live ticker columns ─── */
.w-market__tickers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 0.8rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.w-market__tickers::-webkit-scrollbar { display: none; }
.w-market__tickers { scrollbar-width: none; }

.w-market__col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.w-market__col::-webkit-scrollbar { display: none; }
.w-market__col { scrollbar-width: none; }

.w-market__col-header {
    font-family: var(--rv-font-pixel);
    font-size: 0.6rem;
    color: var(--rv-accent);
    letter-spacing: 0.15em;
    opacity: 0.5;
    margin-bottom: 0.3rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--rv-border);
    flex-shrink: 0;
}

.w-market__list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.w-market__separator {
    font-family: var(--rv-font-mono);
    font-size: 0.6rem;
    color: var(--rv-accent);
    letter-spacing: 0.1em;
    opacity: 0.4;
    text-align: center;
    margin: 0.3rem 0 0.2rem;
    padding: 0.15rem 0;
    flex-shrink: 0;
}

.w-market__row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.25rem;
    border-radius: 2px;
    transition: background 0.2s ease;
    min-height: 1.3rem;
    flex-shrink: 0;
}

.w-market__row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.w-market__row--mine {
    background: rgba(0, 240, 255, 0.04);
    border-left: 2px solid var(--rv-accent);
    position: relative;
}

.w-market__row--mine:hover {
    background: rgba(0, 240, 255, 0.08);
}

.w-market__crypto-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
}

.w-market__crypto-icon img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: block;
}

.w-market__ticker {
    font-family: var(--rv-font-pixel);
    font-size: 0.5rem;
    color: var(--rv-fg-dim);
    letter-spacing: 0.06em;
    min-width: 32px;
    flex-shrink: 0;
}

.w-market__row--mine .w-market__ticker {
    color: var(--rv-accent);
}

.w-market__name {
    font-family: var(--rv-font-mono);
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.45);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.w-market__price {
    font-family: var(--rv-font-mono);
    font-size: 0.8rem;
    color: var(--rv-fg);
    font-weight: 500;
    text-align: right;
    min-width: 50px;
}

.w-market__change {
    font-family: var(--rv-font-mono);
    font-size: 0.65rem;
    text-align: right;
    min-width: 42px;
    flex-shrink: 0;
}

.w-market__change--up { color: #4ade94; }
.w-market__change--down { color: #ff6b6b; }
.w-market__change--flat { color: var(--rv-fg-dim); }

/* Holdings tooltip */
.w-market__tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.92);
    border: 1px solid var(--rv-accent-dim);
    padding: 0.5rem 0.6rem;
    z-index: 20;
    pointer-events: none;
}

.w-market__row--mine:hover .w-market__tooltip {
    display: block;
}

.w-market__tooltip-text {
    font-family: var(--rv-font-mono);
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}

/* Shimmer loading */
.w-market__row--loading .w-market__price,
.w-market__row--loading .w-market__change {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.03) 25%,
        rgba(255,255,255,0.08) 50%,
        rgba(255,255,255,0.03) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    color: transparent;
    border-radius: 2px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.w-market__disclaimer {
    font-family: var(--rv-font-mono);
    font-size: 0.5rem;
    color: rgba(255, 255, 255, 0.2);
    text-align: right;
    padding-top: 0.2rem;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

/* ─── Table headers ─── */
.w-market__thead {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.25rem 0.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 2px;
}

.w-market__th {
    font-family: var(--rv-font-pixel);
    font-size: 0.45rem;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1;
}

.w-market__th--icon { width: 16px; flex-shrink: 0; }
.w-market__th--ticker { min-width: 32px; flex-shrink: 0; }
.w-market__th--name { flex: 1; min-width: 0; }
.w-market__th--price { min-width: 50px; text-align: right; }
.w-market__th--change { min-width: 42px; text-align: right; flex-shrink: 0; }
.w-market__th--5y { min-width: 48px; text-align: right; flex-shrink: 0; }
.w-market__th--shb { min-width: 44px; text-align: center; flex-shrink: 0; }

/* 5Y performance column */
.w-market__5y {
    font-family: var(--rv-font-mono);
    font-size: 0.65rem;
    text-align: right;
    min-width: 48px;
    flex-shrink: 0;
    color: var(--rv-fg-dim);
}

.w-market__5y--up { color: #4ade94; }
.w-market__5y--down { color: #ff6b6b; }

/* S/H/B stacked bar column */
.w-market__shb {
    min-width: 44px;
    flex-shrink: 0;
    cursor: default;
}

.w-market__shb-bar {
    display: flex;
    width: 100%;
    height: 6px;
    border-radius: 2px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
}

.w-market__shb-s,
.w-market__shb-h,
.w-market__shb-b {
    height: 100%;
    width: 0;
    transition: width 0.6s ease;
}

.w-market__shb-s { background: #ff6b6b; }
.w-market__shb-h { background: #fbbf24; }
.w-market__shb-b { background: #4ade94; }

/* Dim bar until data loaded */
.w-market__shb:not(.w-market__shb--loaded) .w-market__shb-bar {
    opacity: 0.3;
}

/* ───────────────────────────────────────────────────────────────
   W5. ASCII ART — Vertical display (2x2)
   ─────────────────────────────────────────────────────────────── */
[data-widget="ascii"] {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.w-ascii__header {
    padding: 0.35rem 0.65rem;
    border-bottom: 1px solid var(--rv-border);
}

.w-ascii__screen {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.w-ascii__screen .hero-ascii {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.w-ascii__screen .ascii-layer {
    top: 50%;
    transform: translate(-50%, -50%);
}

.w-ascii__footer {
    padding: 0.25rem 0.65rem;
    border-top: 1px solid var(--rv-border);
    min-height: 1.4rem;
}

.w-ascii__title {
    font-family: var(--rv-font-mono);
    font-size: 0.7rem;
    color: var(--rv-fg-dim);
    letter-spacing: 0.04em;
    margin: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.w-ascii__title.visible {
    opacity: 1;
}

/* ───────────────────────────────────────────────────────────────
   W7. WEATHER — Temperature + icon
   ─────────────────────────────────────────────────────────────── */
.w-weather {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 0.15rem;
}

.w-weather__icon {
    font-family: var(--rv-font-mono);
    font-size: 0.85rem;
    color: var(--rv-fg-dim);
    line-height: 1.2;
    margin: 0;
    text-align: center;
}

.w-weather__temp {
    font-family: var(--rv-font-mono);
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--rv-fg);
}

.w-weather__wind {
    font-family: var(--rv-font-mono);
    font-size: 0.65rem;
    color: var(--rv-fg-dim);
    letter-spacing: 0.04em;
}

/* ───────────────────────────────────────────────────────────────
   W9. CONTACTS — Social link grid
   ─────────────────────────────────────────────────────────────── */
[data-widget="contacts"] {
    display: flex;
    flex-direction: column;
}

.w-contacts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 5px;
    flex: 1;
    min-height: 0;
    align-content: center;
}

.w-contacts__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: transparent;
    color: rgba(255, 255, 255, 0.25);
    text-decoration: none;
    font-size: 15px;
    padding: 5px 3px;
    transition: color 0.2s ease, border-color 0.2s ease;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.w-contacts__btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1.5px;
    background: var(--btn-color, var(--rv-accent));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
}

.w-contacts__btn:hover {
    color: var(--btn-color, var(--rv-accent));
    border-color: var(--btn-accent, rgba(255, 255, 255, 0.15));
}

.w-contacts__btn:hover::after {
    transform: scaleX(1);
}

.w-contacts__lbl {
    font-family: var(--rv-font-pixel);
    font-size: 0.3rem;
    letter-spacing: 0.05em;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.w-contacts__btn:hover .w-contacts__lbl {
    opacity: 1;
}

.w-contacts__btn--pink   { --btn-accent: rgba(255, 107, 157, 0.35); --btn-color: #ff6b9d; }
.w-contacts__btn--white  { --btn-accent: rgba(255, 255, 255, 0.25); --btn-color: #fff; }
.w-contacts__btn--blue   { --btn-accent: rgba(107, 140, 255, 0.35); --btn-color: #6b8cff; }
.w-contacts__btn--green  { --btn-accent: rgba(74, 222, 148, 0.35);  --btn-color: #4ade94; }
.w-contacts__btn--yellow { --btn-accent: rgba(251, 191, 36, 0.35);  --btn-color: #fbbf24; }
.w-contacts__btn--purple { --btn-accent: rgba(167, 139, 250, 0.35); --btn-color: #a78bfa; }

/* ═══════════════════════════════════════════════════════════════
   WIDGET RESPONSIVE — 768–1023px (Tablet)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
    /* Identity */
    .w-identity__name { font-size: clamp(1.1rem, 2vw, 1.5rem); }
    .w-identity__handle { font-size: 0.7rem; }
    .w-identity__role { font-size: 0.6rem; }
    .w-identity__status { font-size: 0.6rem; }

    /* Clock */
    .w-clock__time { font-size: clamp(0.85rem, 1.5vw, 1.1rem); }
    .w-clock__date { font-size: 0.45rem; }

    /* Coords */
    .w-coords__lat, .w-coords__lon { font-size: 0.7rem; }
    .w-coords__compass { width: 26px; height: 26px; }

    /* Market */
    .w-market__col-header { font-size: 0.42rem; margin-bottom: 0.2rem; }
    .w-market__separator { font-size: 0.5rem; margin: 0.2rem 0 0.15rem; }
    .w-market__ticker { font-size: 0.42rem; }
    .w-market__name { font-size: 0.6rem; }
    .w-market__price { font-size: 0.65rem; }
    .w-market__change { font-size: 0.55rem; }
    .w-market__disclaimer { font-size: 0.42rem; }
    .w-market__row { min-height: 1.1rem; padding: 0.1rem 0.2rem; }

    /* Table headers + 5Y + S/H/B */
    .w-market__th { font-size: 0.3rem; }
    .w-market__5y { font-size: 0.55rem; min-width: 38px; }
    .w-market__shb { min-width: 36px; }
    .w-market__shb-bar { height: 5px; }

    /* Weather */
    .w-weather__icon { font-size: 0.7rem; }
    .w-weather__temp { font-size: 1rem; }
    .w-weather__wind { font-size: 0.55rem; }

    /* Contacts */
    .w-contacts { gap: 4px; }
    .w-contacts__btn { font-size: 14px; padding: 4px 3px; }

    /* ASCII */
    .w-ascii__header { padding: 0.25rem 0.5rem; }
    .w-ascii__footer { padding: 0.2rem 0.5rem; min-height: 1.1rem; }
    .w-ascii__title { font-size: 0.6rem; }
}

/* ═══════════════════════════════════════════════════════════════
   WIDGET RESPONSIVE — 480–767px (Mobile)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    /* Identity */
    .w-identity { gap: 0.5rem; }
    .w-identity__name { font-size: clamp(0.95rem, 4vw, 1.2rem); }
    .w-identity__handle { font-size: 0.6rem; }
    .w-identity__role { font-size: 0.5rem; }
    .w-identity__status { font-size: 0.5rem; }
    .w-identity__status-dot { width: 5px; height: 5px; }

    /* Clock */
    .w-clock__time { font-size: clamp(0.75rem, 3.5vw, 0.95rem); }
    .w-clock__date { font-size: 0.38rem; }

    /* Coords */
    .w-coords__lat, .w-coords__lon { font-size: 0.6rem; }
    .w-coords__compass { width: 22px; height: 22px; top: 0.2rem; right: 0.2rem; }

    /* Market */
    [data-widget="market"] { padding: 0.35rem 0.45rem; }
    .w-market__col-header { font-size: 0.36rem; }
    .w-market__separator { font-size: 0.42rem; margin: 0.15rem 0 0.1rem; }
    .w-market__ticker { font-size: 0.36rem; min-width: 24px; }
    .w-market__name { font-size: 0.5rem; }
    .w-market__price { font-size: 0.55rem; min-width: 36px; }
    .w-market__change { font-size: 0.48rem; min-width: 32px; }
    .w-market__row { gap: 0.2rem; min-height: 1rem; padding: 0.08rem 0.15rem; }
    .w-market__crypto-icon { width: 12px; height: 12px; }
    .w-market__disclaimer { font-size: 0.36rem; }
    /* Table headers + 5Y + S/H/B */
    .w-market__th { font-size: 0.28rem; }
    .w-market__th--icon { width: 12px; }
    .w-market__5y { font-size: 0.48rem; min-width: 32px; }
    .w-market__shb { min-width: 30px; }
    .w-market__shb-bar { height: 4px; }

    /* Weather */
    .w-weather__icon { font-size: 0.6rem; }
    .w-weather__temp { font-size: 0.85rem; }
    .w-weather__wind { font-size: 0.48rem; }

    /* Contacts */
    .w-contacts { gap: 3px; }
    .w-contacts__btn { font-size: 12px; padding: 3px; }
    .w-contacts__lbl { font-size: 0.26rem; }

    /* ASCII */
    .w-ascii__header { padding: 0.2rem 0.4rem; }
    .w-ascii__footer { padding: 0.15rem 0.4rem; min-height: 0.9rem; }
    .w-ascii__title { font-size: 0.5rem; }
}

/* ═══════════════════════════════════════════════════════════════
   WIDGET RESPONSIVE — <480px (Small mobile)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 479px) {
    /* Identity */
    .w-identity { flex-direction: column; align-items: flex-start; gap: 0.2rem; }
    .w-identity__name { font-size: clamp(0.85rem, 4.5vw, 1.05rem); }
    .w-identity__handle { font-size: 0.52rem; }
    .w-identity__role { font-size: 0.42rem; }
    .w-identity__status { font-size: 0.42rem; gap: 4px; }

    /* Clock */
    .w-clock { gap: 0.15rem; }
    .w-clock__time { font-size: clamp(0.65rem, 3.5vw, 0.85rem); }
    .w-clock__date { font-size: 0.32rem; }

    /* Coords */
    .w-coords__lat, .w-coords__lon { font-size: 0.5rem; }
    .w-coords__compass { width: 18px; height: 18px; }

    /* Market — compact */
    [data-widget="market"] { padding: 0.3rem 0.35rem; }
    .w-market__tickers { gap: 0 0.4rem; }
    .w-market__col-header { font-size: 0.3rem; }
    .w-market__separator { font-size: 0.36rem; }
    .w-market__ticker { font-size: 0.3rem; min-width: 20px; }
    .w-market__name { display: none; }
    .w-market__price { font-size: 0.48rem; min-width: 28px; }
    .w-market__change { font-size: 0.4rem; min-width: 26px; }
    .w-market__row { gap: 0.15rem; min-height: 0.85rem; padding: 0.05rem 0.1rem; }
    .w-market__crypto-icon { width: 10px; height: 10px; }
    .w-market__disclaimer { font-size: 0.3rem; }

    /* Table headers + 5Y + S/H/B */
    .w-market__thead { display: none; }
    .w-market__5y { font-size: 0.4rem; min-width: 26px; }
    .w-market__shb { min-width: 22px; }
    .w-market__shb-bar { height: 3px; }

    /* Weather */
    .w-weather__icon { font-size: 0.5rem; }
    .w-weather__temp { font-size: 0.7rem; }
    .w-weather__wind { font-size: 0.4rem; }

    /* Contacts */
    .w-contacts__btn { font-size: 11px; padding: 2px; }
    .w-contacts__lbl { display: none; }

}

/* ───────────────────────────────────────────────────────────────
   PREFERS-REDUCED-MOTION
   ─────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .w-identity__cursor,
    .w-identity__status-dot,
    .w-clock__colon,
    .w-coords__needle {
        animation: none;
    }

    .w-contacts__btn::after {
        transition: none;
    }

    .w-market__row--loading .w-market__price,
    .w-market__row--loading .w-market__change {
        animation: none;
    }
}
