/* =====================================================================
   Soyannalk — main stylesheet
   Modern, mobile-first, CSS-variable driven. No framework dependency.
   Light + dark themes: neutral colours come from variables so a single
   [data-theme="dark"] block flips the whole site. Brand colours are
   injected inline from the admin panel and shared across both themes.
   ===================================================================== */

:root {
    /* Palette matched to the Soyanna.lk logo (blue pin + magnifier).
       --brand / --brand-2 / --brand-soft may be overridden inline by admin. */
    --brand: #2e77c0;          /* logo blue */
    --brand-2: #55a7e8;        /* light sky blue */
    --brand-soft: #e5f1fb;
    --accent: #f59e0b;
    --ink: #16283a;            /* primary text */
    --ink-soft: #51667c;       /* secondary text */
    --bg: #ffffff;             /* page background */
    --bg-alt: #f5f9fd;         /* alternate/section background */
    --surface: #ffffff;        /* cards, inputs, menus, header */
    --header-bg: rgba(255, 255, 255, 0.85);
    --line: #dfeaf4;
    --toast-bg: #16283a;
    --skeleton-mid: #e7f0f9;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 14px;
    --shadow: 0 4px 24px rgba(20, 60, 110, 0.08);
    --shadow-lg: 0 12px 40px rgba(20, 60, 110, 0.16);
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Dark theme — higher specificity than the inline :root brand block so
   these neutral overrides always win, while --brand/--brand-2 stay. */
html[data-theme="dark"] {
    --brand-soft: #1b2f45;
    --ink: #e6edf5;
    --ink-soft: #9fb2c6;
    --bg: #0e1621;
    --bg-alt: #14202e;
    --surface: #17222f;
    --header-bg: rgba(14, 22, 33, 0.85);
    --line: #26333f;
    --toast-bg: #1e2a38;
    --skeleton-mid: #223142;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    /* the off-canvas mobile menu sits beyond the right edge */
    overflow-x: hidden;
    overflow-x: clip;
    transition: background .2s, color .2s;
}
img { max-width: 100%; display: block; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; }

.container { width: min(1140px, 92%); margin-inline: auto; }
.container.narrow { width: min(720px, 92%); }
.muted { color: var(--ink-soft); }
.center { text-align: center; }

/* ---------- Header / nav ---------- */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: transparent;
    border-bottom: 1px solid var(--line);
}
/* Frosted background lives on a pseudo-element. If backdrop-filter sat on
   the header itself it would become the containing block for the fixed
   mobile drawer and clip it to the header's height. */
.site-header::before {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.nav { display: flex; align-items: center; gap: 1rem; height: 64px; }
.brand { display: flex; align-items: center; gap: .5rem; font-size: 1.3rem; font-weight: 800; color: var(--ink); }
.brand em { color: var(--brand); font-style: normal; }
.brand-mark { width: 30px; height: 30px; }
/* Header shows the logo image only (uploadable from the admin panel) */
.brand-logo { height: 42px; width: auto; max-width: 220px; object-fit: contain; display: block; }
.brand-logo-mark { height: 36px; }
html[data-theme="dark"] .brand-logo { filter: brightness(0) invert(1); }
@media (max-width: 720px) { .brand-logo { height: 34px; max-width: 150px; } }
.nav-links { display: flex; align-items: center; gap: 1.4rem; margin-left: auto; }
.nav-links > a { color: var(--ink-soft); font-weight: 500; transition: color .15s; }
.nav-links > a:hover, .nav-links > a.active { color: var(--brand); }

/* Right-side action cluster (theme toggle + auth/profile + hamburger) */
.nav-actions { display: flex; align-items: center; gap: .55rem; }
.nav-auth { display: flex; gap: .5rem; align-items: center; }

/* Dark-mode toggle */
.theme-toggle {
    width: 40px; height: 40px; border-radius: 50%; flex: none;
    border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-soft);
    cursor: pointer; display: grid; place-items: center; transition: .15s;
}
.theme-toggle:hover { color: var(--brand); border-color: var(--brand); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ---------- Profile avatar + dropdown menu ---------- */
.profile-wrap { position: relative; }
.avatar-btn {
    width: 40px; height: 40px; border-radius: 50%; padding: 0; cursor: pointer;
    border: 2px solid var(--surface); overflow: hidden; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 2px 10px rgba(20, 60, 110, .25); transition: box-shadow .15s, transform .12s;
}
.avatar-btn:hover { box-shadow: 0 0 0 3px var(--brand-soft), 0 2px 10px rgba(20, 60, 110, .25); }
.avatar-btn:active { transform: scale(.95); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-initial { color: #fff; font-weight: 700; font-size: 1.05rem; line-height: 1; }
.profile-menu {
    position: absolute; right: 0; top: calc(100% + 12px); width: 240px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    box-shadow: var(--shadow-lg); padding: .45rem; z-index: 150;
}
.profile-menu::before {
    content: ''; position: absolute; top: -6px; right: 14px; width: 12px; height: 12px;
    background: var(--surface); border-left: 1px solid var(--line); border-top: 1px solid var(--line);
    transform: rotate(45deg);
}
.pm-head { display: flex; flex-direction: column; gap: .1rem; padding: .6rem .8rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: .35rem; }
.pm-head .muted { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; }
.pm-item {
    display: block; width: 100%; text-align: left; padding: .55rem .8rem;
    border-radius: 9px; color: var(--ink); font-weight: 500; font-size: .95rem;
    background: none; border: 0; cursor: pointer; font-family: inherit; transition: .12s;
}
.pm-item:hover { background: var(--bg-alt); color: var(--brand); }
.pm-sep { height: 1px; background: var(--line); margin: .35rem 0; }
.pm-danger { color: var(--danger); }
.pm-danger:hover { background: rgba(220, 38, 38, .12); color: var(--danger); }
.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; }
.nav-toggle span { display: block; width: 24px; height: 2.5px; background: var(--ink); margin: 5px 0; border-radius: 2px; transition: .25s; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .55rem 1.2rem; border-radius: 10px; font-weight: 600; font-size: .95rem;
    border: 1.5px solid transparent; cursor: pointer; font-family: inherit;
    transition: transform .12s, box-shadow .12s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 4px 14px rgba(46, 119, 192, .35); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(46, 119, 192, .45); }
.btn-outline { border-color: var(--brand); color: var(--brand); background: transparent; }
.btn-outline:hover { background: var(--brand-soft); }
.btn-ghost { color: var(--ink-soft); background: transparent; }
.btn-ghost:hover { background: var(--bg-alt); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { padding: .8rem 1.7rem; font-size: 1.05rem; }
.btn-sm { padding: .3rem .8rem; font-size: .85rem; }
.btn-block { width: 100%; }

/* ---------- Hero ---------- */
.hero { background: radial-gradient(1200px 500px at 85% -10%, var(--brand-soft), transparent), var(--bg-alt); overflow: hidden; }
.hero-inner { display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; align-items: center; padding: 4.5rem 0; }
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); font-weight: 800; margin: 1rem 0; }
.grad { background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 1.1rem; color: var(--ink-soft); max-width: 46ch; }
.hero-actions { display: flex; gap: .8rem; margin-top: 1.8rem; flex-wrap: wrap; }
.badge { display: inline-block; background: var(--surface); border: 1px solid var(--line); padding: .3rem .9rem; border-radius: 99px; font-size: .85rem; font-weight: 600; box-shadow: var(--shadow); }

.hero-art { position: relative; height: 340px; }
.hero-blob {
    position: absolute; inset: 10% 5%;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border-radius: 42% 58% 60% 40% / 45% 45% 55% 55%;
    opacity: .9; animation: blob 9s ease-in-out infinite alternate;
}
@keyframes blob { to { border-radius: 55% 45% 40% 60% / 55% 60% 40% 45%; } }
.hero-card {
    position: absolute; background: var(--surface); padding: .6rem 1rem; border-radius: 12px;
    box-shadow: var(--shadow-lg); font-weight: 600; font-size: .9rem; white-space: nowrap;
    animation: float 5s ease-in-out infinite;
}
.hc-1 { top: 8%; left: 0; }
.hc-2 { top: 45%; right: 0; animation-delay: 1.2s; }
.hc-3 { bottom: 6%; left: 12%; animation-delay: 2.4s; }
@keyframes float { 50% { transform: translateY(-10px); } }

/* ---------- Portal home ---------- */
.portal-search { width: 100%; max-width: 560px; margin-top: 1.8rem; }
.portal-search .seg { margin-bottom: .9rem; }
.portal-search-row { display: flex; gap: .6rem; background: var(--surface); padding: .45rem; border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.portal-search-row .input { border: 0; font-size: 1rem; min-width: 0; background: transparent; }
.portal-search-row .input:focus { box-shadow: none; }
.hero-art-img { width: 100%; max-width: 520px; height: auto; margin-inline: auto; display: block; }
.hero .hero-art { height: auto; }

.service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1.3rem; }
.service-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow); color: var(--ink);
    display: flex; flex-direction: column; transition: .15s;
}
.service-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--brand); }
.service-card.soon:hover { transform: none; border-color: var(--line); }
.service-art { width: 100%; height: 160px; object-fit: cover; display: block; }
.service-art.placeholder { display: flex; align-items: center; justify-content: center; font-size: 3rem; background: linear-gradient(135deg, var(--bg-alt), var(--brand-soft)); }
.service-body { padding: 1.2rem 1.4rem 1.5rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.service-link { color: var(--brand); font-weight: 700; margin-top: auto; padding-top: .6rem; }

.one-account { display: grid; grid-template-columns: 1.2fr .8fr; gap: 2.5rem; align-items: center; }
.account-perks { display: grid; gap: .8rem; }
.perk { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1.1rem; font-weight: 600; box-shadow: var(--shadow); }
@media (max-width: 860px) { .one-account { grid-template-columns: 1fr; } }

/* ---------- Sections ---------- */
.section { padding: 3.5rem 0; }
.section.alt { background: var(--bg-alt); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.6rem; }
.section-head h2 { font-size: 1.7rem; }
.link-more { font-weight: 600; }
.page-head { background: var(--bg-alt); padding: 2.6rem 0 1.8rem; border-bottom: 1px solid var(--line); }
.page-head h1 { font-size: 2rem; }

/* ---------- Category grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .9rem; }
.cat-tile {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem .8rem; text-align: center; font-weight: 600; color: var(--ink);
    transition: .15s; box-shadow: var(--shadow);
}
.cat-tile:hover { transform: translateY(-3px); border-color: var(--brand); box-shadow: var(--shadow-lg); }
.cat-tile .ico { font-size: 1.7rem; display: block; margin-bottom: .3rem; }

/* ---------- Post cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.2rem; }
.post-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; box-shadow: var(--shadow); transition: .15s; display: flex; flex-direction: column; color: var(--ink);
}
.post-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.post-card .thumb { height: 170px; background: var(--bg-alt); object-fit: cover; width: 100%; }
.post-card .thumb.placeholder { display: flex; align-items: center; justify-content: center; font-size: 2.6rem; }
.post-card .body { padding: 1rem; display: flex; flex-direction: column; gap: .3rem; flex: 1; }
.post-card h3 { font-size: 1.05rem; }
.post-card .meta { font-size: .85rem; color: var(--ink-soft); margin-top: auto; }
.pill { display: inline-block; padding: .15rem .65rem; border-radius: 99px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.pill.lost { background: #fee2e2; color: #b91c1c; }
.pill.found { background: #dcfce7; color: #15803d; }
.pill.resolved { background: #e0e7ff; color: #4338ca; }

/* ---------- Steps ---------- */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem; box-shadow: var(--shadow); }
.step-n {
    width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 800; font-size: 1.1rem; margin-bottom: .8rem;
}

/* ---------- Forms ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-card { padding: 1.8rem; margin-bottom: 1.5rem; }
.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.input {
    width: 100%; padding: .65rem .9rem; border: 1.5px solid var(--line); border-radius: 10px;
    font: inherit; background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field-error { color: var(--danger); font-size: .85rem; margin-top: .25rem; }

.seg { display: inline-flex; background: var(--bg-alt); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg.wide { display: flex; margin-bottom: 1.2rem; }
.seg-btn, .seg-radio span {
    padding: .5rem 1.2rem; border-radius: 9px; font-weight: 600; cursor: pointer;
    border: 0; background: transparent; font-family: inherit; font-size: .95rem; color: var(--ink-soft);
    display: block; text-align: center; transition: .15s;
}
.seg-btn.active, .seg-radio input:checked + span { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.seg-radio { flex: 1; } .seg-radio input { display: none; }

.filter-bar { display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; margin-bottom: 1.6rem; align-items: center; }

/* ---------- Post detail ---------- */
.post-detail { margin-top: 1rem; }
.detail-card { padding: 1.8rem; }
.detail-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.detail-title { font-size: 1.6rem; margin: .4rem 0; }
.detail-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem; margin: 1.2rem 0; }
.detail-imgs img { border-radius: 10px; height: 180px; width: 100%; object-fit: cover; cursor: zoom-in; }
.detail-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .9rem; margin: 1.2rem 0; }
.meta-item { background: var(--bg-alt); border-radius: 10px; padding: .7rem 1rem; }
.meta-item .k { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); font-weight: 700; }
.contact-box { background: var(--brand-soft); border-radius: 12px; padding: 1rem 1.2rem; margin-top: 1rem; font-weight: 600; }

/* ---------- Lists / dashboard ---------- */
.list-stack { display: flex; flex-direction: column; gap: .9rem; }
.list-item {
    display: flex; gap: 1rem; align-items: center; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: .9rem 1.1rem; box-shadow: var(--shadow); flex-wrap: wrap;
}
.list-item .thumb-sm { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--bg-alt); display: grid; place-items: center; font-size: 1.5rem; }
.list-item .grow { flex: 1; min-width: 180px; }
.list-item .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.dash-actions { margin-bottom: 1.4rem; }

/* ---------- Auth pages ---------- */
.auth-section { min-height: 60vh; display: flex; align-items: center; }
.auth-box { width: min(440px, 92%); }
.big-code { font-size: 5rem; font-weight: 800; color: var(--brand); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 2rem; flex-wrap: wrap; }
.page-btn {
    min-width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
    font-weight: 600; cursor: pointer; font-family: inherit; color: var(--ink-soft);
}
.page-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(20, 10, 40, .5); display: grid; place-items: center; z-index: 300; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-box { background: var(--surface); border-radius: var(--radius); padding: 1.6rem; width: min(480px, 100%); box-shadow: var(--shadow-lg); }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 1.4rem; left: 50%; transform: translate(-50%, 20px);
    background: var(--toast-bg); color: #fff; padding: .7rem 1.4rem; border-radius: 12px;
    font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
    transition: .25s; z-index: 400; max-width: 92%;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------- Page loader ---------- */
.page-loader { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 500; pointer-events: none; }
.loader-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .3s; }
.page-loader.loading .loader-bar { width: 80%; }
.page-loader.done .loader-bar { width: 100%; opacity: 0; transition: width .2s, opacity .4s .2s; }

/* ---------- Skeletons ---------- */
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-card, .skeleton-row {
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--bg-alt) 25%, var(--skeleton-mid) 50%, var(--bg-alt) 75%);
    background-size: 200% 100%; animation: shimmer 1.3s infinite;
}
.skeleton-card { height: 280px; } .skeleton-card.tall { height: 420px; }
.skeleton-row { height: 84px; }

/* ---------- Footer (dark in both themes) ---------- */
.site-footer { background: #0f2238; color: #b6c8da; margin-top: 3rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 2rem; padding: 3rem 0 2rem; }
.site-footer h4 { color: #fff; margin-bottom: .8rem; }
.site-footer a { display: block; color: #b6c8da; margin-bottom: .4rem; }
.site-footer a:hover { color: #fff; }
.site-footer .brand { color: #fff; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); padding: 1.2rem 0; font-size: .88rem; }

/* ---------- Misc ---------- */
.prose h2 { margin: 1.4rem 0 .5rem; font-size: 1.3rem; }
.prose p, .prose ul { margin-bottom: .8rem; }
.prose ul { padding-left: 1.3rem; }
.avatar-lg { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 3px solid var(--brand-soft); }
.profile-avatar-row { display: flex; gap: 1.2rem; align-items: center; margin-bottom: 1.2rem; }
.auth-required-note { background: #fff7ed; border: 1px solid #fdba74; color: #7c4a12; padding: 1rem 1.2rem; border-radius: 12px; margin-bottom: 1.2rem; }
html[data-theme="dark"] .auth-required-note { background: #3a2a12; border-color: #7c5312; color: #fcd9a5; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .hero-inner { grid-template-columns: 1fr; padding: 3rem 0; }
    .hero-art { display: none; }
    .steps { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .filter-bar { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .nav-toggle { display: block; }
    /* Navigation menu becomes an off-canvas drawer; the action cluster
       (theme toggle + profile/auth + hamburger) stays in the top bar. */
    .nav-links {
        position: fixed; top: 64px; right: 0; bottom: 0; width: min(300px, 85vw);
        background: var(--surface); flex-direction: column; align-items: flex-start; gap: 1.2rem;
        padding: 1.6rem; box-shadow: var(--shadow-lg); transform: translateX(100%);
        transition: transform .25s; border-left: 1px solid var(--line); margin-left: 0;
    }
    .nav-links.open { transform: translateX(0); }
    .nav-actions { margin-left: auto; }
    .nav-auth .btn { padding: .4rem .85rem; font-size: .85rem; }
    .field-row { grid-template-columns: 1fr; }
    .section { padding: 2.4rem 0; }
}
