/* ============================================================
   TM3 Guide - dark Tesla-inspired stylesheet
   ============================================================ */

:root {
    --bg:        #0d0f12;
    --bg-soft:   #14171c;
    --bg-card:   #1a1e24;
    --bg-input:  #22262e;
    --line:      #2a2f38;
    --text:      #e8eaed;
    --text-dim:  #9aa2ad;
    --accent:    #e82127;   /* Tesla red */
    --accent-hi: #ff3b41;
    --ok:        #2ecc71;
    --warn:      #f1c40f;
    --radius:    12px;
    --shadow:    0 8px 30px rgba(0, 0, 0, .45);
    --font: "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent-hi); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

.wrap { width: min(1120px, 92%); margin: 0 auto; }
.narrow { width: min(520px, 92%); }
.narrow-wide { width: min(760px, 92%); }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: rgba(13, 15, 18, .85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    padding: .65rem 0; gap: 1rem;
}
.brand-logo { height: 34px; display: block; }
.main-nav { display: flex; align-items: center; gap: 1.15rem; flex-wrap: wrap; }
.main-nav a {
    color: var(--text-dim); font-size: .95rem; letter-spacing: .02em;
    transition: color .15s;
}
.main-nav a:hover { color: var(--text); text-decoration: none; }
.main-nav .nav-btn {
    color: #fff; background: var(--accent);
    padding: .42rem .95rem; border-radius: 999px; font-weight: 600;
}
.main-nav .nav-btn:hover { background: var(--accent-hi); }
.main-nav .nav-admin { color: var(--warn); font-weight: 600; }

.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: .5rem; }
.nav-toggle span {
    display: block; width: 24px; height: 2px; margin: 5px 0;
    background: var(--text); transition: transform .2s, opacity .2s;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- News ticker (lysavis) ---------- */
.ticker {
    display: flex; align-items: stretch;
    background: linear-gradient(180deg, #14171c, #0f1216);
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}
.ticker-label {
    flex: 0 0 auto; display: flex; align-items: center; gap: .45rem;
    background: var(--accent); color: #fff;
    font-weight: 800; font-size: .74rem; letter-spacing: .18em;
    padding: 0 1rem; position: relative;
}
.ticker-label::after { /* pulsing LED dot */
    content: ""; width: 7px; height: 7px; border-radius: 50%;
    background: #fff; box-shadow: 0 0 8px #fff;
    animation: ticker-blink 1.4s ease-in-out infinite;
}
.ticker-viewport { flex: 1 1 auto; overflow: hidden; }
.ticker-track {
    display: inline-flex; white-space: nowrap; will-change: transform;
    animation: ticker-scroll 38s linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item {
    display: inline-block; padding: .55rem 0;
    font-family: "Consolas", "SFMono-Regular", "Menlo", monospace;
    font-size: .9rem; letter-spacing: .04em;
    color: #ff5a5f; text-shadow: 0 0 10px rgba(232, 33, 39, .45);
}
.ticker-sep { color: var(--accent); margin: 0 2.5rem; opacity: .8; }

@keyframes ticker-scroll {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}
@keyframes ticker-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: .25; }
}
@media (prefers-reduced-motion: reduce) {
    .ticker-track { animation: none; white-space: normal; display: block; }
    .ticker-item:nth-child(2) { display: none; }
    .ticker-item { white-space: normal; padding: .55rem 1rem; }
    .ticker-sep { display: none; }
    .ticker-label::after { animation: none; }
}

/* ---------- Hero ---------- */
.hero {
    background:
        linear-gradient(180deg, rgba(13,15,18,.25) 0%, rgba(13,15,18,.05) 55%, var(--bg) 100%),
        url("../img/hero-bg.svg") center / cover no-repeat;
    padding: clamp(4rem, 12vw, 8.5rem) 0 clamp(3rem, 9vw, 6.5rem);
    text-align: center;
}
.hero h1 {
    font-size: clamp(2.1rem, 5.5vw, 3.6rem);
    line-height: 1.12; margin: 0 0 1rem;
    font-weight: 700; letter-spacing: .01em;
    text-shadow: 0 2px 24px rgba(0,0,0,.6);
}
.hero .accent { color: var(--accent-hi); }
.hero-sub {
    color: #c9ced6; max-width: 560px; margin: 0 auto 2rem;
    font-size: 1.06rem; text-shadow: 0 1px 12px rgba(0,0,0,.7);
}
.search-form {
    display: flex; max-width: 560px; margin: 0 auto;
    border-radius: 999px; overflow: hidden;
    box-shadow: var(--shadow); border: 1px solid var(--line);
    background: var(--bg-card);
}
.search-form input {
    flex: 1; border: 0; background: transparent; color: var(--text);
    padding: .95rem 1.4rem; font-size: 1rem; outline: none;
}
.search-form button {
    border: 0; background: var(--accent); color: #fff;
    padding: 0 1.8rem; font-size: 1rem; font-weight: 600; cursor: pointer;
    transition: background .15s;
}
.search-form button:hover { background: var(--accent-hi); }

/* ---------- Sections & titles ---------- */
main { flex: 1; padding: 2.2rem 0 3.5rem; }
.page-title {
    font-size: clamp(1.5rem, 3.4vw, 2.1rem); margin: .6rem 0 1.2rem;
    display: flex; align-items: center; gap: .6rem;
}
.title-icon { width: 38px; height: 38px; }
.section-title {
    font-size: 1.25rem; margin: 2.2rem 0 1rem;
    text-transform: uppercase; letter-spacing: .12em;
    color: var(--text-dim); font-weight: 600;
}
.crumbs { color: var(--text-dim); font-size: .88rem; margin: .4rem 0 0; }
.muted { color: var(--text-dim); }
.empty-note { padding: 2rem 0; }

/* ---------- Category cards ---------- */
.cat-grid {
    display: grid; gap: .9rem;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.cat-grid-large { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.cat-card {
    background: var(--bg-card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.1rem .9rem;
    display: flex; flex-direction: column; align-items: center; gap: .55rem;
    color: var(--text); font-weight: 600; font-size: .95rem; text-align: center;
    transition: transform .15s, border-color .15s, background .15s;
}
.cat-card:hover {
    transform: translateY(-3px); border-color: var(--accent);
    background: #1e232b; text-decoration: none;
}
.cat-icon { width: 44px; height: 44px; }
.cat-count { color: var(--text-dim); font-weight: 400; font-size: .82rem; }

/* ---------- Guide cards ---------- */
.guide-grid {
    display: grid; gap: 1.2rem;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.guide-card {
    background: var(--bg-card); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; color: var(--text);
    display: flex; flex-direction: column;
    transition: transform .15s, border-color .15s, box-shadow .15s;
}
.guide-card:hover {
    transform: translateY(-4px); border-color: var(--accent);
    box-shadow: var(--shadow); text-decoration: none;
}
.guide-thumb {
    aspect-ratio: 16 / 9; background-size: cover; background-position: center;
    position: relative; background-color: var(--bg-soft);
}
.badge-video {
    position: absolute; left: .7rem; bottom: .7rem;
    background: rgba(0, 0, 0, .72); color: #fff;
    font-size: .78rem; font-weight: 600; padding: .25rem .7rem;
    border-radius: 999px; border: 1px solid rgba(255,255,255,.18);
}
.guide-card-body { padding: 1rem 1.1rem 1.15rem; }
.guide-card-body h3 { margin: 0 0 .4rem; font-size: 1.08rem; line-height: 1.35; }
.guide-summary { margin: 0 0 .6rem; color: var(--text-dim); font-size: .92rem; }
.guide-meta { margin: 0; color: var(--text-dim); font-size: .84rem; }
.guide-meta strong { color: var(--text); }

/* ---------- Article ---------- */
.article-wrap { width: min(780px, 92%); }
.article-head h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: .4rem 0 .8rem; line-height: 1.2; }
.article-cats { margin: 0; }
.chip {
    display: inline-block; background: var(--bg-card); border: 1px solid var(--line);
    color: var(--text-dim); border-radius: 999px; padding: .18rem .8rem;
    font-size: .8rem; margin: 0 .3rem .3rem 0; font-weight: 600;
}
.chip:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.chip-red { border-color: var(--accent); color: var(--accent-hi); }
.byline { display: flex; align-items: center; gap: .55rem; color: var(--text-dim); margin: 0 0 1.4rem; }
.byline strong { color: var(--text); }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #7a1114);
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .95rem;
}
.video-frame {
    position: relative; aspect-ratio: 16 / 9; margin: 0 0 1.6rem;
    border-radius: var(--radius); overflow: hidden; background: #000;
    border: 1px solid var(--line); box-shadow: var(--shadow);
}
.video-frame iframe, .video-frame video {
    position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.article-cover { border-radius: var(--radius); margin-bottom: 1.6rem; border: 1px solid var(--line); }
.article-lead { font-size: 1.12rem; color: #c9ced6; }
.article-body { font-size: 1.02rem; }
.article-body h2 {
    font-size: 1.3rem; margin: 1.8rem 0 .6rem;
    padding-bottom: .35rem; border-bottom: 1px solid var(--line);
}
.article-body ul { padding-left: 1.3rem; }
.article-body li { margin: .3rem 0; }
.article-foot { border-top: 1px solid var(--line); margin-top: 2.2rem; padding-top: 1rem; }

/* ---------- Forms ---------- */
.form-card {
    background: var(--bg-card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.6rem; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 1.05rem;
}
.form-card label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .95rem; }
.form-card label small { color: var(--text-dim); font-weight: 400; }
.form-card input[type=text], .form-card input[type=email], .form-card input[type=password],
.form-card input[type=url], .form-card input[type=search], .form-card textarea {
    background: var(--bg-input); border: 1px solid var(--line); border-radius: 8px;
    color: var(--text); padding: .7rem .9rem; font-size: 1rem; font-family: var(--font);
    outline: none; transition: border-color .15s;
}
.form-card input:focus, .form-card textarea:focus { border-color: var(--accent); }
.form-card input[type=file] { color: var(--text-dim); font-size: .92rem; }
.form-card textarea { resize: vertical; line-height: 1.55; }
.cat-fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; }
.cat-fieldset legend { font-weight: 600; padding: 0 .4rem; font-size: .95rem; }
.cat-fieldset legend small { color: var(--text-dim); font-weight: 400; }
.cat-checks { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.check { display: flex; align-items: center; gap: .45rem; font-weight: 400; cursor: pointer; }
.check input { accent-color: var(--accent); width: 17px; height: 17px; }

/* honeypot - visually removed but present for bots */
.hp-field { position: absolute; left: -9999px; top: -9999px; height: 0; overflow: hidden; }

.form-inline { display: flex; gap: .5rem; align-items: center; margin: 0 0 1.1rem; flex-wrap: wrap; }
.form-inline input[type=text] {
    background: var(--bg-input); border: 1px solid var(--line); border-radius: 8px;
    color: var(--text); padding: .5rem .8rem;
}
.inline-input {
    background: var(--bg-input); border: 1px solid var(--line); border-radius: 6px;
    color: var(--text); padding: .35rem .6rem; font-size: .85rem; max-width: 150px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; background: var(--bg-input); color: var(--text);
    border: 1px solid var(--line); border-radius: 999px;
    padding: .6rem 1.4rem; font-size: .95rem; font-weight: 600;
    cursor: pointer; transition: background .15s, border-color .15s;
    font-family: var(--font);
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hi); }
.btn-small { padding: .32rem .85rem; font-size: .83rem; }
.btn-ok { background: #1d6b40; border-color: #1d6b40; color: #fff; }
.btn-ok:hover { background: #238a51; border-color: #238a51; }
.btn-danger { background: transparent; border-color: #93262a; color: #ff8a8e; }
.btn-danger:hover { background: #93262a; color: #fff; border-color: #93262a; }

/* ---------- Flash messages ---------- */
.flash {
    border-radius: 10px; padding: .85rem 1.1rem; margin: .9rem 0;
    border: 1px solid; font-size: .95rem;
}
.flash-success { background: #10281a; border-color: #1d6b40; color: #a7e6c3; }
.flash-error   { background: #2b1214; border-color: #93262a; color: #ffb3b6; }
.flash-info    { background: #10202e; border-color: #2b567a; color: #a9cfec; }

/* ---------- Tables ---------- */
.table {
    width: 100%; border-collapse: collapse; margin: 1rem 0;
    background: var(--bg-card); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; font-size: .93rem;
}
.table th, .table td { padding: .7rem .9rem; text-align: left; vertical-align: top; }
.table thead th {
    background: var(--bg-soft); color: var(--text-dim);
    text-transform: uppercase; letter-spacing: .08em; font-size: .76rem;
}
.table tbody tr { border-top: 1px solid var(--line); }
.table tbody tr:hover { background: #1e232b; }
.actions form { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }

.status {
    display: inline-block; padding: .15rem .65rem; border-radius: 999px;
    font-size: .78rem; font-weight: 700; border: 1px solid;
}
.status-ok      { color: #7be0a8; border-color: #1d6b40; background: #10281a; }
.status-pending { color: #f4d67c; border-color: #8a7519; background: #241f0d; }
.status-bad     { color: #ff9a9e; border-color: #93262a; background: #2b1214; }

/* ---------- Admin dashboard ---------- */
.stat-grid {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.stat-card {
    background: var(--bg-card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1.3rem; color: var(--text-dim);
    display: flex; flex-direction: column; gap: .3rem; font-weight: 600;
    transition: border-color .15s;
}
.stat-card:hover { border-color: var(--accent); text-decoration: none; }
.stat-num { font-size: 2.3rem; color: var(--text); font-weight: 700; line-height: 1; }
.stat-alert { border-color: var(--accent); }
.stat-alert .stat-num { color: var(--accent-hi); }

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--line); background: var(--bg-soft);
    padding: 2.2rem 0; margin-top: 2rem;
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 2rem; align-items: flex-start; justify-content: space-between; }
.footer-logo { height: 26px; opacity: .85; }
.footer-tag { color: var(--text-dim); font-size: .88rem; margin: .5rem 0 0; max-width: 320px; }
.footer-links { display: flex; flex-direction: column; gap: .45rem; }
.footer-links a { color: var(--text-dim); font-size: .92rem; }
.footer-links a:hover { color: var(--text); }
.footer-note { color: #5d6570; font-size: .8rem; margin: 0; flex-basis: 100%; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .nav-toggle { display: block; }
    .main-nav {
        display: none; position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 0;
        background: var(--bg-soft); border-bottom: 1px solid var(--line);
        padding: .5rem 0;
    }
    .main-nav.open { display: flex; }
    .main-nav a { padding: .8rem 1.4rem; }
    .main-nav .nav-btn { border-radius: 0; margin: .3rem 1.4rem; text-align: center; }
    .table { display: block; overflow-x: auto; }
}
