/* ============================================
   TechFriendsIRL — stylesheet
   Design direction: "warm terminal" — a dark
   console palette with a classic green-phosphor
   CRT accent (think old monochrome terminals),
   monospace headings, humane sans body copy. The
   signature element is the phosphor-green caret-
   blink on the logo and chip-style interest tags
   that look like shell flags ( --linux, --rust ).
   ============================================ */

:root {
    --bg: #11151a;
    --bg-raised: #161c23;
    --bg-card: #1b222b;
    --line: #2a3340;
    --text: #e8ecef;
    --text-dim: #9aa7b2;
    --text-faint: #5f6c78;
    --phosphor: #4fd675;
    --phosphor-bright: #8af0a0;
    --green: #7fd9a8;
    --cyan: #6ec8dc;
    --red: #e8746b;

    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

img { max-width: 100%; }

input[type=checkbox], input[type=radio] {
    accent-color: var(--phosphor);
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    overflow-x: hidden;
    width: 100%;
}

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
}

a { color: var(--phosphor); text-decoration: none; }
a:hover { color: var(--phosphor-bright); text-decoration: underline; }

h1, h2, h3, h4 {
    font-family: var(--font-mono);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 0.5em;
    color: var(--text);
}

/* ---------- Header ---------- */
.site-header {
    border-bottom: 1px solid var(--line);
    background: var(--bg-raised);
    position: sticky;
    top: 0;
    z-index: 10;
}
.site-header .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding-top: 8px;
    padding-bottom: 8px;
    position: relative;
}
.logo {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--phosphor);
    position: relative;
}
.logo::after {
    content: '_';
    color: var(--phosphor-bright);
    animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Hamburger toggle: hidden by default (desktop). The checkbox drives
   visibility purely with CSS, so the mobile menu works with zero JS. */
.nav-toggle-input { display: none; }
.nav-toggle-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    width: 36px;
    height: 36px;
    cursor: pointer;
    flex-shrink: 0;
}
.nav-toggle-btn span {
    display: block;
    width: 22px;
    height: 2px;
    margin: 3px 0;
    background: var(--text-dim);
    border-radius: 1px;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

nav { display: flex; align-items: center; }
nav a, nav a.btn-link { margin-left: 20px; }
nav a:first-child { margin-left: 0; }
nav a {
    color: var(--text-dim);
    font-size: 0.92rem;
}
nav a:hover { color: var(--text); text-decoration: none; }
nav a.btn-link {
    color: var(--phosphor);
    border: 1px solid var(--phosphor);
    padding: 6px 14px;
    border-radius: 4px;
}
nav a.btn-link:hover {
    background: var(--phosphor);
    color: var(--bg);
}
.badge {
    background: var(--red);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 7px;
    margin-left: 2px;
}

/* ---------- Footer ---------- */
.site-footer {
    border-top: 1px solid var(--line);
    margin-top: 64px;
    padding: 28px 0;
    color: var(--text-faint);
    font-size: 0.85rem;
}

/* ---------- Flash messages ---------- */
.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 20px 0;
    font-size: 0.92rem;
    border: 1px solid;
}
.flash-success { background: rgba(127,217,168,0.08); border-color: var(--green); color: var(--green); }
.flash-error   { background: rgba(232,116,107,0.08); border-color: var(--red); color: var(--red); }
.flash ul { margin: 0; padding-left: 20px; }

/* ---------- Hero / landing ---------- */
.hero {
    padding: 72px 0 48px;
    text-align: left;
    max-width: 720px;
}
.hero h1 {
    font-size: 2.4rem;
    line-height: 1.15;
    margin-bottom: 0.6em;
}
.hero .tagline {
    color: var(--text-dim);
    font-size: 1.08rem;
    margin-bottom: 2em;
}
.cta-row { display: flex; gap: 14px; }

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 32px 0 64px;
    border-top: 1px solid var(--line);
    margin-top: 24px;
}
.feature {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
}
.feature h3 { font-size: 1rem; margin-bottom: 0.5em; }
.feature p { color: var(--text-dim); font-size: 0.92rem; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.92rem;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 5px;
    border: 1px solid transparent;
    cursor: pointer;
}
.btn-primary {
    background: var(--phosphor);
    color: #1a1208;
}
.btn-primary:hover { background: var(--phosphor-bright); text-decoration: none; }
.btn-secondary {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}
.btn-secondary:hover { border-color: var(--text-dim); text-decoration: none; }
.btn-danger {
    background: transparent;
    border-color: var(--red);
    color: var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-link {
    color: var(--phosphor);
    font-size: 0.92rem;
    background: none;
    border: none;
    cursor: pointer;
}

/* ---------- Forms ---------- */
fieldset {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}
legend {
    font-family: var(--font-mono);
    color: var(--phosphor);
    padding: 0 8px;
    font-size: 0.9rem;
}
.hint { color: var(--text-faint); font-weight: 400; font-size: 0.85rem; }
.field-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 400;
}
.field-hint #usernamePreview { color: var(--phosphor); }

label {
    display: block;
    margin-bottom: 14px;
    font-size: 0.88rem;
    color: var(--text-dim);
}
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=url], select, textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 0.95rem;
    font-family: var(--font-body);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--phosphor);
}
textarea { resize: vertical; font-family: var(--font-body); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.interest-group { margin-bottom: 16px; }
.interest-group h4 {
    font-size: 0.8rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
.interest-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    cursor: pointer;
    color: var(--text-dim);
    margin: 0;
}
.chip input { width: auto; margin: 0; }
.chip:has(input:checked) {
    border-color: var(--phosphor);
    color: var(--phosphor-bright);
    background: rgba(79,214,117,0.1);
}

.auth-form { max-width: 640px; margin: 40px auto; }
.auth-form-narrow { max-width: 420px; }
.auth-form h1 { margin-bottom: 0.3em; }
.muted { color: var(--text-faint); font-size: 0.9rem; }

/* ---------- Browse / filter ---------- */
.browse { padding: 32px 0 64px; }
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 24px 0 32px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}
.filter-bar input, .filter-bar select {
    width: auto;
    flex: 1 1 160px;
}
.hint-box {
    background: var(--bg-card);
    border: 1px dashed var(--line);
    border-radius: 6px;
    padding: 14px 16px;
    color: var(--text-dim);
    font-size: 0.92rem;
}

.member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}
.member-card {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.member-card-head {
    display: flex;
    align-items: center;
    gap: 10px;
}
.member-card-head h3 { flex: 1; min-width: 0; font-size: 1rem; margin: 0; overflow-wrap: break-word; }
.match-badge {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    background: rgba(110,200,220,0.12);
    color: var(--cyan);
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
}
.member-meta { color: var(--text-faint); font-size: 0.85rem; margin: 0; }
.member-bio { color: var(--text-dim); font-size: 0.88rem; margin: 4px 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.chip-static {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-dim);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 3px 8px;
}
.chip-static::before { content: '--'; color: var(--text-faint); }
.chip-shared {
    border-color: var(--phosphor);
    color: var(--phosphor-bright);
}
.chip-more { color: var(--text-faint); }
.chip-more::before { content: ''; }
.member-card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
}

/* ---------- Avatars ---------- */
.avatar {
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg);
    border: 1px solid var(--line);
    flex-shrink: 0;
}
.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-faint);
    background: var(--bg-card);
}
.avatar-sm { width: 40px; height: 40px; font-size: 1rem; }
.avatar-lg { width: 88px; height: 88px; font-size: 2rem; }

.profile-header {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.profile-header h1 { margin: 0; }

.avatar-edit-row {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.avatar-edit-controls {
    display: flex;
    flex-direction: column;
}
.avatar-edit-controls > * { margin-top: 8px; }
.avatar-edit-controls > *:first-child { margin-top: 0; }
.file-label {
    font-size: 0.88rem;
    color: var(--text-dim);
    margin: 0;
}
.file-label input[type=file] {
    display: block;
    margin-top: 6px;
    width: auto;
    background: none;
    border: none;
    padding: 0;
    color: var(--text-dim);
    font-size: 0.85rem;
}
.remove-avatar-chip {
    width: fit-content;
}

/* ---------- Profile view ---------- */
.profile-view { max-width: 680px; margin: 32px auto 64px; }
.username { color: var(--text-faint); font-family: var(--font-mono); font-size: 0.9rem; font-weight: 400; }
.profile-header-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.profile-header-text > * { margin-top: 8px; }
.profile-header-text > *:first-child { margin-top: 0; }
.profile-section {
    border-top: 1px solid var(--line);
    padding: 18px 0;
}
.profile-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
}
.small { font-size: 0.82rem; }

.public-link-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 14px;
    margin: 14px 0 24px;
    flex-wrap: wrap;
}
.public-link-label {
    font-size: 0.78rem;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.public-link-box code {
    font-family: var(--font-mono);
    color: var(--phosphor-bright);
    font-size: 0.9rem;
}

.public-cta {
    margin-top: 28px;
    background: var(--bg-card);
    border: 1px solid var(--phosphor);
    border-radius: 8px;
    padding: 22px;
}
.public-cta h3 {
    font-size: 1rem;
    color: var(--phosphor-bright);
    text-transform: none;
    letter-spacing: 0;
}
.public-cta p {
    color: var(--text-dim);
    font-size: 0.92rem;
    margin: 0 0 16px;
}
.public-cta .cta-row { margin: 0; }

/* ---------- Messages ---------- */
.messages-list, .message-view { max-width: 760px; margin: 32px auto 64px; }
.messages-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
}
.tab {
    padding: 10px 18px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
}
.tab.active { color: var(--phosphor); border-color: var(--phosphor); }
.tab:hover { text-decoration: none; color: var(--text); }

.message-table { display: flex; flex-direction: column; }
.message-row {
    display: grid;
    grid-template-columns: 180px 1fr 1fr 130px 16px;
    gap: 14px;
    align-items: center;
    padding: 12px 8px;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font-size: 0.88rem;
}
.message-row:hover { background: var(--bg-card); text-decoration: none; }
.message-row.unread { font-weight: 700; }
.message-row.unread .msg-preview { color: var(--text); }
.msg-from { color: var(--text-dim); }
.msg-from .username { font-size: 0.78rem; }
.msg-subject { color: var(--text); }
.msg-preview { color: var(--text-faint); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 400; }
.msg-date { color: var(--text-faint); font-family: var(--font-mono); font-size: 0.78rem; text-align: right; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--phosphor); }

.back-link { display: inline-block; margin-bottom: 16px; color: var(--text-dim); font-size: 0.88rem; }
.message-meta { color: var(--text-faint); font-size: 0.88rem; margin-bottom: 24px; }
.message-body {
    background: var(--bg-card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    white-space: pre-wrap;
    margin-bottom: 20px;
}
.message-actions { display: flex; gap: 10px; }
.inline-form { display: inline; }

/* ============================================
   Responsive
   ============================================ */

/* Tablet and below: tighten spacing, collapse multi-column grids */
@media (max-width: 760px) {
    .wrap { padding: 0 16px; }

    .features { grid-template-columns: 1fr; }
    .row-2, .row-3 { grid-template-columns: 1fr; }

    .hero { padding: 40px 0 32px; }
    .hero h1 { font-size: 1.9rem; }
    .cta-row { flex-wrap: wrap; }
    .cta-row .btn { flex: 1 1 auto; text-align: center; }

    /* --- Mobile nav: hamburger + dropdown panel, pure CSS --- */
    .nav-toggle-btn { display: flex; }
    nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: var(--bg-raised);
        border-bottom: 1px solid var(--line);
        box-shadow: 0 8px 16px rgba(0,0,0,0.3);
        padding: 8px 0;
        z-index: 20;
    }
    .nav-toggle-input:checked ~ nav { display: flex; }
    .nav-toggle-input:checked ~ .nav-toggle-btn span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .nav-toggle-input:checked ~ .nav-toggle-btn span:nth-child(2) { opacity: 0; }
    .nav-toggle-input:checked ~ .nav-toggle-btn span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
    nav a {
        padding: 14px 24px;
        font-size: 1rem;
        border-bottom: 1px solid var(--line);
        width: 100%;
        margin-left: 0;
    }
    nav a:last-child { border-bottom: none; }
    nav a.btn-link {
        margin: 8px 24px 0;
        text-align: center;
        width: auto;
        border-bottom: 1px solid var(--phosphor);
    }

    .filter-bar { padding: 12px; }
    .filter-bar input, .filter-bar select { flex: 1 1 100%; }
    .filter-bar button, .filter-bar .btn-link { flex: 1 1 auto; }

    .member-grid { grid-template-columns: 1fr; }

    .avatar-edit-row { flex-direction: column; align-items: flex-start; }

    .profile-header { gap: 14px; }
    .profile-header-text { width: 100%; }
    .profile-header-text .btn { width: 100%; text-align: center; }

    .message-row {
        grid-template-columns: 1fr;
        gap: 4px;
        position: relative;
        padding: 14px 8px;
    }
    .msg-date { text-align: left; }
    .message-row .dot { position: absolute; top: 14px; right: 8px; }

    .message-actions { flex-wrap: wrap; }
    .message-actions .btn,
    .message-actions .inline-form { flex: 1 1 auto; }
    .message-actions .inline-form { display: flex; }
    .message-actions .inline-form .btn { width: 100%; }
    .message-actions .btn { text-align: center; }

    .public-cta .cta-row { flex-direction: column; }
    .public-cta .cta-row .btn { width: 100%; text-align: center; }
}

/* Phones: further tighten, stack remaining side-by-side elements */
@media (max-width: 480px) {
    .wrap { padding: 0 14px; }
    html, body { font-size: 15px; }

    .hero h1 { font-size: 1.6rem; }
    .hero .tagline { font-size: 1rem; }

    fieldset { padding: 14px; }

    .avatar-lg { width: 72px; height: 72px; font-size: 1.6rem; }

    .member-card-actions { flex-direction: column; }
    .member-card-actions .btn { width: 100%; text-align: center; }

    .public-link-box { flex-direction: column; align-items: flex-start; }

    .interest-chips { gap: 6px; }
    .chip { padding: 8px 12px; } /* keep tap target comfortable at smaller gaps */

    .messages-tabs { gap: 0; }
    .tab { flex: 1 1 auto; text-align: center; padding: 12px 10px; }

    .member-card-head { flex-wrap: wrap; }
    .match-badge { margin-left: 50px; } /* aligns under the name, past the avatar */
}

/* Safety net at any width: never let long unbroken strings (emails,
   URLs, usernames) force horizontal scrolling on narrow screens. */
.message-meta, .username, .profile-section a, .public-link-box code,
.member-bio, .message-body {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .logo::after { animation: none; }
    .nav-toggle-btn span { transition: none; }
}
