/* =========================================================
   krchowdhary.css: Computer Science Learning Portal
   Concept: a well-typeset textbook page. Serif for course
   titles and headings, sans for interface text, ruled
   sections instead of boxed cards.
   Replaces krcssgpt.css (keep the old file until you
   have checked every inner page).
========================================================= */

:root {
    --ink:        #17203d;   /* header background, headings */
    --ink-soft:   #2a3560;
    --paper:      #f8f9fb;   /* page background */
    --surface:    #ffffff;
    --text:       #1e2433;
    --muted:      #596277;
    --rule:       #d8dde8;
    --link:       #0b6b7a;
    --link-hover: #084e59;
    --mark:       #e0a526;   /* single warm accent, used on primary button and focus */
    --on-ink:     #f3f5fa;
    --on-ink-dim: #b9c2d8;

    --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
    --sans:  "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    /* Names used by the old stylesheet; kept so old inline styles and pages still resolve */
    --primary:      var(--link);
    --primary-dark: var(--ink);
    --accent:       var(--mark);
    --bg:           var(--paper);
    --text-light:   var(--muted);
    --border:       var(--rule);
    --radius:       6px;
    --shadow:       0 1px 3px rgba(23, 32, 61, .12);
    --transition:   .15s ease;

    --measure: 68ch;
    --wrap: 70rem;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

body {
    margin: 0;
    background: var(--paper);
    color: var(--text);
    font: 400 1.0625rem/1.65 var(--sans);
}

img { max-width: 100%; height: auto; }

a { color: var(--link); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; border-radius: 2px; }

.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }

.skip-link {
    position: absolute; left: 1rem; top: -4rem; z-index: 100;
    background: var(--surface); color: var(--ink); padding: .6rem 1rem; border-radius: 4px;
}
.skip-link:focus { top: 1rem; }

/* ---------- Header ---------- */
.site-header { background: var(--ink); color: var(--on-ink); padding: 3rem 0 2.75rem; }
.site-header__inner { display: grid; grid-template-columns: 1fr auto; gap: 2.5rem; align-items: center; }

.site-header h1 {
    margin: 0 0 .6rem;
    font: 700 clamp(2rem, 4.5vw, 3.25rem)/1.1 var(--serif);
    letter-spacing: -0.015em;
    text-wrap: balance;
}
.site-header__lead { margin: 0 0 1.5rem; max-width: 46ch; font-size: 1.2rem; color: var(--on-ink); }
.site-header__actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0 0 1.75rem; }
.site-header__byline { margin: 0; max-width: 62ch; font-size: .95rem; line-height: 1.55; color: var(--on-ink-dim); }
.site-header__byline strong { color: var(--on-ink); font-weight: 600; }

.site-header__photo {
    width: 180px; height: 180px; object-fit: cover;
    border-radius: 6px; border: 3px solid var(--ink-soft);
}
/* .profile-photo as a standalone element (about page etc.) */
.profile-photo { overflow: hidden; }
.site-header .profile-photo { border-radius: 6px; }
div.profile-photo { width: 140px; height: 140px; border-radius: 50%; border: 3px solid var(--rule); }
div.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.site-header .subtitle { background: none; border: 0; padding: 0; }

.btn {
    display: inline-block; padding: .65rem 1.2rem; border-radius: 4px;
    font-weight: 600; text-decoration: none; line-height: 1.2;
    transition: background-color .15s, color .15s, border-color .15s;
}
.btn--primary { background: var(--mark); color: var(--ink); border: 2px solid var(--mark); }
.btn--primary:hover { background: #ecb94a; border-color: #ecb94a; color: var(--ink); }
.btn--ghost { color: var(--on-ink); border: 2px solid var(--on-ink-dim); }
.btn--ghost:hover { border-color: var(--on-ink); background: rgba(255,255,255,.08); color: #fff; }

/* ---------- Navigation (styles whatever nav.php outputs: <nav><ul><li><a>) ---------- */
nav { background: var(--surface); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 100; }
nav ul { display: flex; flex-wrap: wrap; gap: .1rem 1.75rem; margin: 0 auto; padding: .35rem 0; list-style: none; width: min(100% - 2.5rem, var(--wrap)); }
nav a { display: inline-block; padding: .55rem 0; color: var(--ink); font-weight: 500; text-decoration: none; border-bottom: 2px solid transparent; }
nav a:hover, nav a[aria-current="page"] { color: var(--link-hover); border-bottom-color: var(--mark); }

/* ---------- Sections ---------- */
main { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; padding-bottom: 2rem; }

.section { padding: 3rem 0 1rem; border-top: 1px solid var(--rule); scroll-margin-top: 3.5rem; }
.section:first-child { border-top: 0; padding-top: 3rem; }

h2, h3 { font-family: var(--serif); color: var(--ink); text-wrap: balance; }
h2 { margin: 0 0 .75rem; font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h3 { margin: 0 0 .5rem; font-size: 1.2rem; line-height: 1.3; font-weight: 600; }

.section__intro { max-width: var(--measure); margin: 0 0 1.75rem; color: var(--text); }
p { max-width: var(--measure); }

/* ---------- Course materials ---------- */
.course-search { margin: 0 0 2rem; max-width: 26rem; }
.course-search label { display: block; margin-bottom: .3rem; font-weight: 600; font-size: .95rem; color: var(--ink); }
.course-search input {
    width: 100%; padding: .65rem .85rem; font: inherit; color: var(--text);
    background: var(--surface); border: 1px solid #9aa3b8; border-radius: 4px;
}
.course-search input:focus { border-color: var(--ink); }

.course-groups, .two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 3.5rem; align-items: start; }
.course-group[hidden], .course-list li[hidden], .course-empty[hidden] { display: none; }
.course-group h3, .two-col h3 { padding-bottom: .4rem; border-bottom: 2px solid var(--ink); margin-bottom: 0; }

.course-list { list-style: none; margin: 0 0 2rem; padding: 0; }
.course-list li { padding: .85rem 0; border-bottom: 1px solid var(--rule); }
.course-list a { font: 600 1.15rem/1.3 var(--serif); }
.course-list span, .file-list span { display: block; margin-top: .15rem; font-size: .95rem; color: var(--muted); }
.course-empty { margin: 0 0 2rem; color: var(--muted); }

/* ---------- Books ---------- */
.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2.5rem 2rem; margin-bottom: 1.5rem; }
.book { display: flex; flex-direction: column; gap: 1rem; }
.book img {
    width: 100%; max-width: 12rem; aspect-ratio: 3 / 4; object-fit: contain; object-position: left bottom;
    background: var(--surface); border: 1px solid var(--rule);
}
.book h3 { margin-bottom: .1rem; }
.book__meta { margin: 0 0 .5rem; font-size: .95rem; color: var(--muted); }
.book p { margin-top: 0; }
.book__links { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-weight: 500; }
.books-more { margin: 0; color: var(--muted); }

/* ---------- Two columns, services ---------- */

.service-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem 2.5rem; margin-bottom: 1.5rem; }
.service-grid ul { margin: 0; padding-left: 1.1rem; }
.service-grid li { margin-bottom: .25rem; }

/* ---------- About ---------- */
.profile { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 3rem; align-items: start; margin-bottom: 1.5rem; }
.profile__text p:first-child { margin-top: 0; }
.more { font-weight: 600; }

.profile__side { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 1.5rem; }
.stats { margin: 0 0 1.5rem; display: grid; gap: 0; }
.stats div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--rule); }
.stats div:first-child { padding-top: 0; }
.stats dt { color: var(--muted); font-size: .95rem; }
.stats dd { margin: 0; font: 700 1.5rem/1 var(--serif); color: var(--ink); }
.profile-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; }

/* ---------- Contact ---------- */
.contact { padding-bottom: 2rem; text-align: left; }
.contact__mail { font-weight: 600; font-size: 1.15rem; }
.social { list-style: none; display: flex; gap: .75rem; padding: 0; margin: 1.25rem 0 0; }
.social a, .social-icons a {
    display: grid; place-items: center; width: 2.75rem; height: 2.75rem;
    border: 1px solid var(--rule); border-radius: 50%; background: var(--surface);
    color: var(--ink); font-size: 1.25rem; text-decoration: none;
    transition: background-color .15s, color .15s, border-color .15s;
}
.social a:hover, .social-icons a:hover { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

/* ---------- Footer (styles whatever footer.php outputs) ---------- */
footer { margin-top: 2rem; padding: 1.75rem 0; border-top: 4px solid var(--mark); background: var(--ink); color: var(--on-ink-dim); font-size: .95rem; text-align: center; }
footer a { color: var(--on-ink); }
footer a:hover { color: var(--mark); }
footer p { margin: 0 auto; max-width: none; color: inherit; }
.site-footer__copy { margin-bottom: .75rem; color: var(--on-ink); font-weight: 500; }
.site-footer__links { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1.5rem; margin: 0 0 1rem; padding: 0; }
.site-footer__links li { margin: 0; }
.site-footer__stats { padding-top: 1rem; border-top: 1px solid var(--ink-soft); font-size: .88rem; }
.site-footer__stats p { margin: 0 auto .25rem; }

/* ---------- Responsive ---------- */
@media (max-width: 56rem) {
    .book-grid, .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile { grid-template-columns: 1fr; gap: 2rem; }
}
@media (max-width: 42rem) {
    body { font-size: 1rem; }
    .site-header { padding: 2rem 0; }
    .site-header__inner { grid-template-columns: 1fr; }
    .site-header__photo { order: -1; width: 112px; height: 112px; }
    .course-groups, .two-col, .book-grid, .service-grid { grid-template-columns: 1fr; gap: 0; }
    .service-grid { gap: 1.5rem; }
    .book { flex-direction: row; gap: 1rem; margin-bottom: 1.5rem; }
    .book img { width: 6.5rem; flex: none; }
    .section { padding-top: 2.25rem; }
}

/* =========================================================
   Compatibility with inner pages written for krcssgpt.css
   (remove blocks here once the pages no longer use them)
========================================================= */

/* .card: old boxed section, now a ruled section like .section */
.card, main > section:not(.section) { padding: 2.5rem 0 1rem; border-top: 1px solid var(--rule); scroll-margin-top: 3.5rem; }
main > .card:first-child, main > section:not(.section):first-child { border-top: 0; }
.card ol { padding-left: 1.4rem; }
.card ol li { margin-bottom: 1.1rem; }
.card ul { padding-left: 1.2rem; }
.card li { margin-bottom: .45rem; }

/* .button: old link button, same look as the primary header button but on light pages */
.button { display: inline-block; padding: .6rem 1.2rem; background: var(--ink); color: var(--on-ink);
    border-radius: 4px; font-weight: 600; text-decoration: none; transition: background-color .15s; }
.button:hover { background: var(--ink-soft); color: #fff; }

.course-note { color: var(--muted); font-size: .92em; }
.date { display: inline-block; margin-top: .25rem; color: var(--muted); font-size: .95rem; font-style: italic; }
.highlighted { background: #fff3c4; border-bottom: 2px solid var(--mark); font-weight: 600; }

/* Old book cover helper */
.book-cover img { display: block; width: 180px; max-width: 100%; height: auto; margin-inline: auto; }

/* Hidden-until-toggled images */
.toggle-image { display: none; max-width: 20rem; width: 100%; border-radius: 4px; margin: .75rem 0 1.25rem; border: 1px solid var(--rule); }

/* Photo gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1.5rem; }
.photo { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.photo img { display: block; width: 100%; }
.photo p { margin: 0; padding: .9rem 1rem; text-align: center; color: var(--text); }

/* Old icon row (social-icons) */
.social-icons { display: flex; gap: .75rem; margin-top: 1rem; }

/* Old homepage blocks (academic-presence, stats-grid), in case other pages still use them */
.academic-presence-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.5rem 2.5rem; }
.presence-block h3 { padding-bottom: .4rem; border-bottom: 2px solid var(--ink); }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1.5rem; }
.stat { color: var(--muted); font-size: .95rem; line-height: 1.35; }
.stat strong { display: block; font: 700 1.5rem/1.1 var(--serif); color: var(--ink); }
.social-icons a:hover .fa-linkedin  { color: #0077b5; }
.social-icons a:hover .fa-facebook  { color: #1877f2; }
.social-icons a:hover .fa-twitter,
.social-icons a:hover .fa-x-twitter { color: #000; }
.social-icons a:hover .fa-youtube   { color: #c4302b; }

/* Form fields */
input[type="text"], input[type="search"], input[type="email"], textarea {
    font: inherit; color: var(--text); background: var(--surface); border: 1px solid #9aa3b8; border-radius: 4px; padding: .6rem .8rem; }
input[type="text"]:focus, input[type="email"]:focus, textarea:focus { border-color: var(--ink); }

/* Feedback form */
#feedback { display: block; clear: both; }
#feedback form { width: 100%; max-width: 44rem; }
#feedback input[type="text"], #feedback input[type="email"], #feedback textarea { width: 100%; max-width: 41rem; margin-bottom: .75rem; }
#feedback textarea { resize: vertical; min-height: 9rem; }
#feedback button { padding: .6rem 1.2rem; font: 600 1rem var(--sans); color: var(--on-ink); background: var(--ink);
    border: 0; border-radius: 4px; cursor: pointer; }
#feedback button:hover { background: var(--ink-soft); }

@media (max-width: 42rem) {
    input[type="text"], input[type="search"] { width: 100%; max-width: 25rem; }
}

/* Search page */
.search-result { width: 100%; padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.search-result h3 { margin-bottom: .2rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.page-heading { margin: 0 0 1rem; font: 700 clamp(1.6rem, 3vw, 2.1rem)/1.2 var(--serif); color: var(--ink); }

.site-search { display: flex; gap: .6rem; max-width: 36rem; margin-bottom: 1.5rem; }
.site-search input { flex: 1; min-width: 0; width: auto; }
.site-search .btn { border: 2px solid var(--mark); cursor: pointer; font: 600 1rem var(--sans); }

.search-count { color: var(--muted); margin: 0 0 .5rem; }
.search-result p { margin: 0; color: var(--text); }
.search-result a { font-family: var(--serif); }
mark { background: #fff3c4; color: inherit; border-bottom: 2px solid var(--mark); padding: 0 .1em; }

/* nav search box */
nav ul .nav-search { margin-left: auto; }
.nav-search input { padding: .35rem .7rem; width: 11rem; font-size: .95rem; }
@media (max-width: 42rem) {
    nav ul .nav-search { margin-left: 0; width: 100%; }
    .nav-search input { width: 100%; max-width: none; }
    .site-search { flex-direction: column; }
}

/* ---------- Inner pages: course facts, file lists, notes ---------- */
.course-meta { margin: 0 0 1rem; max-width: var(--measure); }
.course-meta div { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--rule); }
.course-meta div:first-child { border-top: 1px solid var(--rule); }
.course-meta dt { color: var(--muted); font-size: .95rem; }
.course-meta dd { margin: 0; }

.file-list { list-style: none; margin: 0 0 2rem; padding: 0; max-width: 52rem; }
.file-list li { padding: .75rem 0; border-bottom: 1px solid var(--rule); }
.file-list li:first-child { border-top: 1px solid var(--rule); }
.file-list a { font-weight: 600; overflow-wrap: anywhere; }

.note { max-width: var(--measure); margin: 0 0 1.5rem; padding: .9rem 1.1rem; background: var(--surface); border-left: 4px solid var(--mark); }
code { font: .92em ui-monospace, "Cascadia Code", Consolas, monospace; background: #eef0f5; padding: .1em .35em; border-radius: 3px; }

@media (max-width: 42rem) {
    .course-meta div { grid-template-columns: 1fr; gap: .1rem; }
}

/* =========================================================
   Stop-gap for inner pages NOT yet converted:
   styles bare <header>, <nav> inside it, <section>, <aside>
   so old pages look acceptable until you update them.
   Delete this block once every page uses .site-header.
========================================================= */
body > header:not(.site-header) { background: var(--ink); color: var(--on-ink); padding: 2rem 0 0; text-align: center; }
body > header:not(.site-header) h1 { margin: .75rem 1.25rem 1.25rem; font: 700 clamp(1.7rem, 4vw, 2.6rem)/1.15 var(--serif); }
body > header:not(.site-header) .profile-photo { margin-inline: auto; }
body > header:not(.site-header) nav { position: static; border-bottom: 0; }
body > header:not(.site-header) nav ul { justify-content: center; }
/* Subtitle under the h1 (any <p> directly in the header, or .header-subtitle). The global "p { max-width }" rule leaves it left-aligned, so centre the block itself. */
body > header:not(.site-header) > p,
body > header:not(.site-header) .header-subtitle { max-width: 48rem; margin: 0 auto 1.75rem; padding-inline: 1.25rem; color: var(--on-ink-dim); }

main aside { margin: 0 0 1.5rem; }
main aside ul { list-style: none; margin: 0; padding: 0; }
main aside li { padding: .6rem 0; border-bottom: 1px solid var(--rule); }
main aside li p { margin: 0; }


/* ---------- Print: handy for lecture-note pages ---------- */
@media print {
    .site-header, nav, footer, .course-search, .site-search, .social, .skip-link { display: none; }
    body { background: #fff; font-size: 11pt; }
    a { color: inherit; }
}
