/* ===================================================================
   ÁRVORE DE LINKS — página pública (/links) e editor (/links/admin)
   Padrão Infinity: tokens.css carrega antes deste arquivo; aqui só se USA var(--...).
   Receitas (raios, sombras, brilho, tipografia) seguem design-system/README.md §4, §5 e §9;
   o padrão de tela está documentado no §11 ("Árvore de links").
   - Página pública: não carrega style.css (fica leve); peças com prefixo lt-.
   - Editor: usa as classes do app (style.css); aqui só o que é dele, com prefixo la-.
   =================================================================== */

/* chuva binária: mesmas regras do app (js/components/binary-rain.js) */
:where(.has-binary-rain) { position: relative; }
.has-binary-rain { isolation: isolate; overflow: hidden; }
.has-binary-rain > .binary-rain { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: -1; pointer-events: none; opacity: 0.5; }

/* ===================================================================
   PÁGINA PÚBLICA
   =================================================================== */

.lt-body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: #000;
    color: var(--text);
    font: 16px/1.5 var(--font-body);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}
.lt-body *, .lt-body *::before, .lt-body *::after { box-sizing: border-box; }
.lt-body img { display: block; max-width: 100%; }
.lt-body ::selection { background: rgba(255, 27, 255, 0.35); }
.lt-body :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* fundo = tela de entrada do app (.auth-screen): preto + chuva + brilho magenta/violeta */
.lt-rain {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(180deg, #000, rgba(0, 0, 0, 0.35) 85%);
    mask-image: linear-gradient(180deg, #000, rgba(0, 0, 0, 0.35) 85%);
}
.lt-body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(800px 520px at 100% -10%, rgba(255, 27, 255, 0.26), transparent 62%),
        radial-gradient(700px 520px at 0% 110%, rgba(123, 92, 255, 0.2), transparent 62%),
        linear-gradient(180deg, rgba(29, 29, 33, 0.55), rgba(20, 20, 22, 0.7));
}
.lt-backdrop { display: none; }

.lt-page {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: 24px 16px calc(24px + var(--safe-b));
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* a partir de 640 px: coluna = painel (--surface) no centro; em volta, a capa desfocada + a chuva */
@media (min-width: 641px) {
    .lt-backdrop {
        display: block;
        position: fixed;
        inset: -80px;
        z-index: 0;
        background: center / cover no-repeat;
        filter: blur(70px) saturate(1.3);
        opacity: 0.55;
        pointer-events: none;
    }
    .lt-page:not(.is-preview) {
        background: rgba(6, 6, 7, 0.94);
        box-shadow: 0 0 0 1px var(--line-2), var(--shadow-2);
    }
}

/* capa (hero): do topo até o nome, de ponta a ponta, se desfazendo no fundo */
.lt-hero { margin: -24px -16px 0; }
.lt-hero img {
    width: 100%;
    aspect-ratio: 4 / 5;
    max-height: 560px;
    object-fit: cover;
    -webkit-mask-image: linear-gradient(180deg, #000 45%, rgba(0, 0, 0, 0.55) 72%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 45%, rgba(0, 0, 0, 0.55) 72%, transparent 100%);
}

.lt-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; text-shadow: 0 1px 10px #000, 0 0 2px #000; }
.lt-head.has-hero { position: relative; z-index: 1; margin-top: -120px; }
/* foto = .avatar-xl do app (88 px) com borda tonal e o brilho do logo */
.lt-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    border: 2px solid var(--accent-line);
    background: var(--surface-3);
    overflow: hidden;
    filter: drop-shadow(0 0 10px var(--accent-glow));
}
.lt-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lt-avatar.is-logo { background: var(--surface); }
.lt-avatar.is-logo img { object-fit: contain; padding: 18px 12px; }
/* nome = .page-title do app: 2rem, 500, caixa alta, .12em */
.lt-name { margin: 6px 0 0; font-size: 2rem; font-weight: 500; line-height: 1.1; letter-spacing: 0.12em; text-transform: uppercase; overflow-wrap: anywhere; }
/* bio = .page-sub */
.lt-bio { margin: 0; max-width: 40ch; color: var(--text-2); font-size: 0.9rem; overflow-wrap: anywhere; white-space: pre-line; }

/* redes: ícone de traço, alvo de 44 px */
.lt-socials { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.lt-social { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; color: var(--text); transition: color 0.15s, background 0.15s; }
.lt-social:hover { color: var(--accent); background: var(--accent-soft); }

.lt-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
/* título de seção = .eyebrow do app */
.lt-label { margin: 10px 0 -2px; font-size: 0.68rem; font-weight: 500; line-height: 1.3; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); overflow-wrap: anywhere; text-shadow: 0 0 6px #000; }

/* botão de link = .card do app (painel, borda, raio 16, --shadow-1) com o hover de card */
.lt-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    padding: 12px 52px;
    border-radius: var(--r-lg);
    border: 1px solid var(--line-2);
    background: var(--surface);
    box-shadow: var(--shadow-1);
    color: var(--text);
    text-decoration: none;
    text-align: center;
    overflow-wrap: anywhere;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease), background 0.15s;
}
.lt-link:hover { color: var(--text); border-color: var(--accent-line); transform: translateY(-3px); box-shadow: var(--shadow-1), 0 0 34px -10px var(--accent-glow); }
.lt-link:active { transform: translateY(1px); }
.lt-link-text { display: flex; flex-direction: column; gap: 3px; }
.lt-link-text b { font-size: 1rem; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.lt-link-text small { font-size: 0.8rem; line-height: 1.35; color: var(--text-2); }
/* miniatura = .avatar do app (borda --line-2, fundo --surface-3) */
.lt-thumb { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 1.5px solid var(--line-2); background: var(--surface-3); }
/* destaque = .btn-primary do app; o editor deixa só um por página */
.lt-link.is-hot { border-color: transparent; background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset, 0 8px 24px -6px var(--accent-glow); }
.lt-link.is-hot .lt-link-text b { text-transform: uppercase; letter-spacing: 0.04em; }
.lt-link.is-hot .lt-link-text small { color: var(--accent-ink); }
.lt-link.is-hot .lt-link-text small { opacity: 0.8; }
.lt-link.is-hot .lt-thumb { border-color: rgba(26, 0, 26, 0.35); }
.lt-link.is-hot:hover { color: var(--accent-ink); background: var(--accent-hover); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset, 0 10px 30px -4px rgba(255, 27, 255, 0.55); }

/* rodapé = .auth-foot do app, em faixa no fim da tela */
.lt-foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: auto -16px calc(-24px - var(--safe-b));
    padding: 18px 16px calc(18px + var(--safe-b));
    border-top: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-3);
    font-size: 0.75rem;
    text-align: center;
}
.lt-foot img { filter: drop-shadow(0 0 10px var(--accent-glow)); }
.lt-empty { margin: 30px 0; text-align: center; color: var(--text-2); }

.lt-loading { display: grid; place-items: center; min-height: 60vh; }
.lt-loading span { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: lt-spin 0.8s linear infinite; }
@keyframes lt-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .lt-body *, .lt-body *::before, .lt-body *::after { animation: none !important; transition: none !important; }
}

/* ===================================================================
   EDITOR (/links/admin) — em cima do style.css do app
   =================================================================== */

.la-body [hidden] { display: none !important; }
/* a entrada (body.auth-mode, .auth-rain, #auth-screen) é a do app: js/auth.js + style.css */
.la-body.auth-mode #view-editor { display: none; }

/* barra do topo: mesmo vidro das ações fixas do app (.upload-actions) */
.la-top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(12px + var(--safe-t)) 40px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(6, 6, 7, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.la-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.la-brand .brand-mark { width: 44px; }
.la-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.la-main { max-width: 1320px; margin: 0 auto; padding: 36px 40px 130px; }
.la-tabs { display: none; }
.la-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 30px; align-items: start; }
.la-editor { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.la-help-top { margin: -8px 0 14px; }
.la-count { float: right; color: var(--text-3); letter-spacing: 0; font-family: var(--font-mono); }

/* capa (usa .dropzone do app quando vazia) e foto (.avatar-lg) */
.la-hero { border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line-2); background: var(--field); }
.la-hero img { width: 100%; max-height: 240px; object-fit: cover; }
.la-hero .dropzone { display: block; width: 100%; padding: 26px 20px; color: var(--text); }
.la-hero .dropzone-title, .la-hero .dropzone-hint { display: block; }
.la-hero:has(.dropzone:not([hidden])) { border: 0; background: none; }
.la-avatar-btn { padding: 0; border-radius: 50%; }
.la-avatar-btn .avatar { filter: drop-shadow(0 0 10px var(--accent-glow)); border-color: var(--accent-line); }
.la-avatar-btn .avatar.is-logo { object-fit: contain; padding: 10px 7px; background: var(--surface); }
#avatar-field.is-muted { opacity: 0.45; }

/* redes: input com ícone à esquerda (mesmas medidas do .search do app) */
.la-socials { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.la-social { position: relative; display: block; }
.la-social .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.la-social .input { padding-left: 38px; }
.la-social:focus-within .ico { color: var(--accent); }

/* lista de links: cada item é um .card-tight; título de seção com borda tracejada */
.la-items { display: flex; flex-direction: column; gap: 12px; }
.la-item {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    background: var(--surface-2);
    transition: opacity 0.15s, border-color 0.2s var(--ease);
}
.la-item.is-title { grid-template-columns: auto minmax(0, 1fr) auto; background: transparent; border-style: dashed; border-color: var(--line-2); }
.la-item:focus-within { border-color: var(--accent-line); }
.la-item.is-off { opacity: 0.55; }
.la-item-move { display: flex; flex-direction: column; gap: 4px; }
.la-up .ico { transform: rotate(180deg); }
.la-thumb { padding: 0; border-radius: 50%; display: grid; place-items: center; }
.la-thumb .avatar { display: grid; place-items: center; color: var(--text-3); }
.la-thumb.is-empty .avatar { border-style: dashed; }
.la-thumb:hover .avatar { border-color: var(--accent-line); color: var(--accent); }
.la-item-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.la-item-body .badge { align-self: flex-start; }
.la-title { font-weight: 600; }
.la-item-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.la-item-tools .checkbox { min-height: 32px; padding: 0 6px; }
/* destaque ligado: estado tonal (como .badge-accent); o magenta sólido fica só no botão da página */
.la-hot.is-on { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

/* prévia: celular de mockup com as medidas do .phone da landing (raio 34, padding 9) */
.la-preview { position: sticky; top: 96px; }
.la-phone { position: relative; width: 340px; margin: 0 auto; padding: 9px; border-radius: 34px; background: #050506; border: 1px solid var(--line-2); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.95), 0 0 50px -20px var(--accent-glow); }
.la-phone-rain { position: absolute; inset: 9px; border-radius: 26px; background: #000; }
.la-phone-screen { position: relative; z-index: 1; height: min(680px, calc(100vh - 150px)); overflow-y: auto; border-radius: 26px; scrollbar-width: none; }
.la-phone-screen::-webkit-scrollbar { display: none; }
.lt-page.is-preview { padding-top: 22px; gap: 18px; min-height: 100%; }
.lt-page.is-preview .lt-hero { margin-top: -22px; }
.lt-page.is-preview a { cursor: default; }
.lt-page.is-preview .lt-name { font-size: 1.6rem; }

/* barra de salvar: vidro das ações fixas do app, raio de card */
.la-savebar {
    position: fixed;
    left: 50%;
    bottom: calc(16px + var(--safe-b));
    transform: translateX(-50%);
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 8px 8px 18px;
    border-radius: var(--r-lg);
    border: 1px solid var(--line-2);
    background: rgba(6, 6, 7, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-2);
    font-size: 0.85rem;
    color: var(--text-2);
}
.la-savebar.is-dirty { border-color: var(--accent-line); color: var(--text); }
.la-savebar .btn { min-width: 110px; }

@media (max-width: 960px) {
    .la-top { padding: calc(10px + var(--safe-t)) 16px 10px; }
    .la-main { padding: 20px 16px 120px; }
    .la-tabs { display: flex; margin-bottom: 16px; }
    .la-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .la-body[data-tab=edit] .la-preview { display: none; }
    .la-body[data-tab=preview] .la-editor { display: none; }
    .la-preview { position: static; }
    .la-phone { width: 100%; max-width: 360px; }
    .la-phone-screen { height: auto; min-height: 560px; overflow: visible; }
}

@media (max-width: 560px) {
    .la-brand > div { display: none; }
    .la-actions { gap: 6px; }
    .la-socials { grid-template-columns: minmax(0, 1fr); }
    .la-item { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "thumb body move" "tools tools tools"; }
    .la-item.is-title { grid-template-areas: "body body move" "tools tools tools"; }
    .la-thumb { grid-area: thumb; align-self: start; }
    .la-item-move { grid-area: move; align-self: start; }
    .la-item-body { grid-area: body; }
    .la-item-tools { grid-area: tools; padding-top: 10px; border-top: 1px solid var(--line); }
    .la-savebar { left: 16px; right: 16px; transform: none; justify-content: space-between; }
}
