/* ============================================================
   SawTutorial — clean editorial "learning portal" identity
   (GeeksforGeeks-inspired: light neutral surfaces, green accent,
   high-contrast readable text, compact card grids)
   Palette:
     --green      #2f8d46  primary brand / links / accents
     --green-dark #1e6b34  hover / pressed state
     --ink        #1a1a1a  headings, nav text (true neutral, not tinted)
     --text       #333333  body copy
     --muted      #737373  secondary text
     --paper      #ffffff  page background
     --surface    #f6f7f6  alternating section tint (near-white)
     --line       #e6e8e6  hairline borders
   Type: system sans stack (Segoe UI / Roboto-adjacent), no monospace identity.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&display=swap');

:root {
    --green: #2f8d46;
    --green-dark: #1e6b34;
    --green-light: #eaf7ee;
    --ink: #1a1a1a;
    --paper: #ffffff;
    --surface: #f6f7f6;
    --card: #ffffff;
    --line: #e6e8e6;
    --text: #333333;
    --muted: #737373;
    --sans: 'Roboto', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
    --radius: 6px;
}

* { box-sizing: border-box; }

body {
    font-family: var(--sans);
    color: var(--text);
    background: var(--paper);
    line-height: 1.65;
    margin: 0;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.25; color: var(--ink); }
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); text-decoration: underline; }

/* ---------- Nav ---------- */
.site-nav {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(23,29,23,.03);
    padding: .5rem 0;
}
.brand {
    display: inline-flex; align-items: center; gap: .5rem;
    font-family: var(--sans); font-weight: 900; font-size: 1.3rem;
    color: var(--ink) !important; text-decoration: none; letter-spacing: -.01em;
}
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--green); color: #fff; font-weight: 800; font-size: .85rem;
    width: 28px; height: 28px; border-radius: 6px; font-family: var(--mono);
}
.site-nav .nav-link {
    color: var(--ink) !important; font-weight: 500; font-size: .93rem;
    padding: .55rem .8rem !important; border-radius: 4px;
}
.site-nav .nav-link:hover { color: var(--green) !important; background: var(--green-light); }
.site-nav .dropdown-toggle::after { vertical-align: .12em; }
.site-nav .dropdown-menu {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(23,29,23,.1); padding: .4rem;
}
.site-nav .dropdown-item { color: var(--text); border-radius: 4px; padding: .5rem .7rem; font-size: .92rem; }
.site-nav .dropdown-item:hover { background: var(--green-light); color: var(--green-dark); }
.site-nav .dropdown-divider { border-color: var(--line); margin: .3rem 0; }
.site-nav .navbar-toggler { border-color: var(--line); }
.site-nav .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(23,29,23,0.85)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
.search-input {
    background: var(--surface); border: 1px solid var(--line); color: var(--text);
    border-radius: 4px; padding-inline: .9rem; min-width: 200px;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus {
    background: #fff; color: var(--ink);
    border-color: var(--green); box-shadow: 0 0 0 .2rem rgba(47,141,70,.15);
}

/* ---------- Hero ---------- */
.hero {
    background: var(--surface);
    border-radius: var(--radius);
    padding: clamp(2.2rem, 5vw, 3.5rem);
    position: relative;
}
.hero h1 { font-size: clamp(1.9rem, 4.2vw, 2.7rem); color: var(--ink); }
.hero h1 .accent { color: var(--green); }
.hero p.lead { color: var(--muted); max-width: 62ch; font-size: 1.05rem; }

.btn-primary-code {
    background: var(--green); color: #fff; border: 1px solid var(--green); font-weight: 600;
    border-radius: 4px; padding: .6rem 1.3rem;
}
.btn-primary-code:hover { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.btn-ghost-code {
    background: #fff; color: var(--ink); border: 1px solid var(--line);
    border-radius: 4px; padding: .6rem 1.3rem; font-weight: 600;
}
.btn-ghost-code:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }

/* ---------- Section headings ---------- */
.section-head { display: flex; flex-direction: column; gap: .2rem; margin: 2.75rem 0 1.2rem; }
.section-head .tag {
    font-family: var(--sans); color: var(--green); font-size: .78rem;
    font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
}
.section-head h2 {
    font-size: 1.55rem; margin: 0; padding-left: .7rem;
    border-left: 4px solid var(--green);
}

/* ---------- Cards ---------- */
.card-tutorial {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    height: 100%; display: flex; flex-direction: column;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.card-tutorial:hover { border-color: var(--green); box-shadow: 0 6px 18px rgba(23,29,23,.08); }
.card-tutorial .body { padding: 1.25rem; display: flex; flex-direction: column; flex: 1; }
.card-tutorial .cat {
    display: inline-block; align-self: flex-start;
    background: var(--green-light); color: var(--green-dark);
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    padding: .2rem .55rem; border-radius: 3px;
}
.card-tutorial h3 { font-size: 1.1rem; margin: .55rem 0 .5rem; }
.card-tutorial h3 a { color: var(--ink); }
.card-tutorial h3 a:hover { color: var(--green); text-decoration: none; }
.card-tutorial .summary { color: var(--muted); font-size: .92rem; flex: 1; }
.card-tutorial .meta {
    font-size: .78rem; color: var(--muted); font-weight: 500;
    margin-top: .9rem; padding-top: .75rem; border-top: 1px solid var(--line);
}

/* Category chips */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1rem; }
.cat-card {
    background: var(--card); color: var(--text); border: 1px solid var(--line);
    border-top: 3px solid var(--green);
    border-radius: var(--radius); padding: 1.3rem; display: block;
}
.cat-card:hover { border-color: var(--green); box-shadow: 0 6px 18px rgba(23,29,23,.08); text-decoration: none; color: var(--text); }
.cat-card .icon {
    font-size: 1.3rem; display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; background: var(--green-light); border-radius: 8px;
}
.cat-card h3 { color: var(--ink); font-size: 1.1rem; margin: .7rem 0 .3rem; }
.cat-card p { color: var(--muted); font-size: .88rem; margin: 0; }

/* Interview level cards */
.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 1.1rem; }
.level-card {
    border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem;
    background: var(--card); display: block; color: var(--text);
    border-top: 3px solid var(--green);
}
.level-card.experienced { border-top-color: #1976d2; }
.level-card.ai { border-top-color: #8e44ad; }
.level-card:hover { text-decoration: none; border-color: var(--green); box-shadow: 0 6px 18px rgba(23,29,23,.08); }
.level-card .count { font-family: var(--sans); font-size: 2rem; font-weight: 900; color: var(--green); }
.level-card h3 { font-size: 1.15rem; margin: .2rem 0; color: var(--ink); }
.level-card p { color: var(--muted); font-size: .9rem; margin: 0; }

/* ---------- Article ---------- */
.tutorial-layout { display: flex; align-items: flex-start; gap: 2.5rem; max-width: 1040px; margin: 0 auto; }
.article-wrap { max-width: 760px; flex: 1 1 auto; min-width: 0; }

.toc-sidebar { flex: 0 0 220px; position: sticky; top: 90px; }
.toc-title {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); margin: 0 0 .6rem;
}
.toc-nav { display: flex; flex-direction: column; }
.toc-nav a {
    display: block; padding: .32rem 0 .32rem .8rem; font-size: .86rem; line-height: 1.3;
    color: var(--muted); text-decoration: none; border-left: 2px solid var(--line);
}
.toc-nav a:hover { color: var(--green-dark); }
.toc-nav a.active { color: var(--green-dark); font-weight: 600; border-left-color: var(--green); }

.toc-mobile {
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
    padding: .8rem 1rem; margin-bottom: 1.5rem;
}
.toc-mobile summary { font-weight: 700; font-size: .9rem; cursor: pointer; }
.toc-mobile .toc-nav { margin-top: .7rem; }
.toc-mobile .toc-nav a { padding: .4rem 0 .4rem .8rem; }

@media (max-width: 991.98px) {
    .tutorial-layout { display: block; }
}

/* ---------- Category topic explorer (sidebar + detail pane) ---------- */
.cat-explorer { display: flex; align-items: flex-start; gap: 2.5rem; }

.cat-sidebar { flex: 0 0 260px; min-width: 0; }
.cat-eyebrow {
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); margin: 0 0 .4rem;
}
.cat-title { display: flex; align-items: center; gap: .6rem; font-size: 1.15rem; margin: 0 0 1rem; }
.cat-accent-bar { display: inline-block; width: 4px; height: 1.05em; background: var(--green); border-radius: 2px; flex-shrink: 0; }

.cat-topic-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.cat-topic {
    display: block; padding: .65rem .8rem .65rem .85rem; font-size: .92rem; color: var(--ink);
    text-decoration: none; border-bottom: 1px solid var(--line); border-left: 3px solid transparent;
    transition: background-color .12s ease, border-color .12s ease;
}
.cat-topic:hover { background: var(--surface); text-decoration: none; }
.cat-topic.is-active { background: var(--green-light); border-left-color: var(--green); font-weight: 600; }

.cat-detail { flex: 1 1 auto; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 1.75rem 2rem; }
.cat-badge {
    display: inline-block; background: var(--green-light); color: var(--green-dark);
    font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
    padding: .2rem .6rem; border-radius: 3px; margin-bottom: .7rem;
}
.cat-detail-title { font-size: 1.5rem; margin: 0 0 .6rem; }
.cat-detail-meta { font-size: .82rem; color: var(--muted); margin: 0 0 1.3rem; }
.cat-detail-body { max-width: 720px; }

@media (max-width: 991.98px) {
    .cat-explorer { display: block; }
    .cat-sidebar { margin-bottom: 1.5rem; }
}
.article-header .cat {
    display: inline-block; background: var(--green-light); color: var(--green-dark);
    font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    padding: .2rem .6rem; border-radius: 3px;
}
.article-header h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin: .6rem 0 .4rem; }
.article-meta { color: var(--muted); font-size: .85rem; font-weight: 500; }
.article-body { font-size: 1.06rem; }
.article-body h2 {
    font-size: 1.4rem; margin: 2rem 0 .8rem; padding-left: .6rem;
    border-left: 4px solid var(--green);
}
.article-body h3 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
.article-body p { margin: 0 0 1.1rem; }
.article-body code {
    font-family: var(--mono); background: var(--surface); color: #b5296b;
    padding: .12em .4em; border-radius: 4px; font-size: .88em;
}
.article-body pre {
    background: var(--ink); color: #ececec; padding: 1.1rem 1.25rem;
    border-radius: var(--radius); overflow-x: auto; font-family: var(--mono);
}
.article-body pre code { background: none; color: inherit; padding: 0; }

/* ---------- Interview Q&A (accordion) ---------- */
.qa-item { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .75rem; background: var(--card); }
.qa-q {
    width: 100%; text-align: left; background: none; border: none;
    padding: 1rem 1.2rem; font-weight: 600; color: var(--ink);
    display: flex; justify-content: space-between; gap: 1rem; align-items: center;
}
.qa-q .idx { color: var(--green); font-weight: 700; font-size: .85rem; }
.qa-q .chev { transition: transform .2s ease; color: var(--muted); }
.qa-q[aria-expanded="true"] .chev { transform: rotate(180deg); }
.qa-a { padding: 0 1.2rem 1.1rem; color: var(--text); display: none; }
.qa-a.open { display: block; }

/* level filter pills */
.filter-pills { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.4rem; }
.pill {
    font-size: .82rem; font-weight: 500; padding: .35rem .9rem;
    border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff;
}
.pill.active, .pill:hover { border-color: var(--green); background: var(--green-light); color: var(--green-dark); text-decoration: none; }

/* ---------- Ads ---------- */
.ad-slot { margin: 2rem auto; text-align: center; min-height: 90px; }

/* ---------- Cookie banner ---------- */
.cookie-banner {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1050;
    background: var(--ink); color: #dcdcdc; padding: .9rem 0;
    border-top: 1px solid var(--line); font-size: .9rem;
}
.cookie-banner a { color: #6fd390; }
.btn-accept { background: var(--green); color: #fff; border: none; font-weight: 600; }
.btn-accept:hover { background: var(--green-dark); color: #fff; }

/* ---------- Footer ---------- */
.site-footer {
    background: var(--ink); color: #b9c2b9; padding: 3rem 0 1.5rem; margin-top: 4rem;
    border-top: 3px solid var(--green);
}
.site-footer h6 { color: #fff; font-size: .95rem; margin-bottom: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.footer-tag { color: #a3a3a3; font-size: .9rem; }
.footer-links { list-style: none; padding: 0; margin: 0; }
.footer-links li { margin-bottom: .5rem; }
.footer-links a { color: #c2c2c2; font-size: .9rem; }
.footer-links a:hover { color: #6fd390; }
.footer-bottom {
    border-top: 1px solid #333333; margin-top: 2rem; padding-top: 1.2rem;
    font-size: .82rem; color: #999999;
}

/* ---------- Admin ---------- */
.admin-shell { max-width: 1000px; margin: 0 auto; }
.admin-table { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat-card { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 1.5rem; }
.stat-card .n { font-size: 2.2rem; font-weight: 900; color: #6fd390; }

/* ---------- Utilities ---------- */
.prose-page { max-width: 720px; margin: 0 auto; }
.prose-page h1 { margin-bottom: 1rem; }
.prose-page h2 {
    font-size: 1.25rem; margin: 1.8rem 0 .6rem; padding-left: .6rem;
    border-left: 4px solid var(--green);
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

/* tag row on article */
.tag-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* WYSIWYG editor (admin) */
.wysiwyg { background: #fff; }
.wysiwyg .ql-editor { min-height: 300px; font-size: .98rem; }
#editor.wysiwyg { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
