/* HSC/SSC GPA Calculator BD — main stylesheet */
:root {
  --c-primary: #1a7a4c;
  --c-primary-dark: #145c39;
  --c-primary-soft: #e8f5ee;
  --c-accent: #f5a524;
  --c-accent-dark: #d4890f;
  --c-bg: #f7faf8;
  --c-bg-elevated: #ffffff;
  --c-text: #12211a;
  --c-text-muted: #3d5348;
  --c-border: #d5e5db;
  --c-danger: #c0392b;
  --c-danger-bg: #fdecea;
  --c-shadow: 0 8px 24px rgba(18, 33, 26, 0.08);
  --c-shadow-sm: 0 2px 8px rgba(18, 33, 26, 0.06);
  --radius: 12px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --font-body: "Hind Siliguri", sans-serif;
  --font-display: "Baloo Da 2", sans-serif;
  --header-h: 4rem;
  --max-w: 1120px;
  --transition: 180ms ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #0e1612;
    --c-bg-elevated: #16211b;
    --c-text: #e8f2ec;
    --c-text-muted: #a8bfb2;
    --c-border: #2a3d33;
    --c-primary-soft: #1a3026;
    --c-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --c-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --c-danger-bg: #3a1c18;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.7;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(26, 122, 76, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(245, 165, 36, 0.1), transparent 45%),
    var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--c-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color var(--transition);
}

a:hover {
  color: var(--c-accent-dark);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.3;
  font-weight: 600;
  margin: 0 0 var(--space-4);
  color: var(--c-text);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.35rem); }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
h3 { font-size: 1.2rem; }

p { margin: 0 0 var(--space-4); }

.container {
  width: min(100% - 2rem, var(--max-w));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--c-bg-elevated) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--c-shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  gap: var(--space-4);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--c-text);
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.logo-en {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--c-primary);
  font-size: 1.05rem;
}

.logo-bn {
  font-size: 0.75rem;
  color: var(--c-text-muted);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
}

.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--c-text);
  border-radius: 2px;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list a {
  display: block;
  padding: 0.4rem 0.65rem;
  text-decoration: none;
  color: var(--c-text-muted);
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
}

.nav-list a:hover,
.nav-list a.is-active {
  color: var(--c-primary);
  background: var(--c-primary-soft);
}

/* Main layout */
.page-hero {
  padding: var(--space-6) 0 var(--space-4);
}

.page-hero .lead {
  font-size: 1.1rem;
  color: var(--c-text-muted);
  max-width: 42rem;
}

.breadcrumbs {
  margin-bottom: var(--space-4);
  font-size: 0.9rem;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--c-text-muted);
}

.breadcrumbs li:not(:last-child)::after {
  content: "/";
  margin-left: var(--space-2);
  opacity: 0.5;
}

.breadcrumbs a {
  text-decoration: none;
}

.content-section {
  padding: var(--space-5) 0;
}

.content-section + .content-section {
  padding-top: 0;
}

.prose {
  max-width: 44rem;
}

.prose ul {
  padding-left: 1.25rem;
  margin-bottom: var(--space-4);
}

.steps {
  display: grid;
  gap: var(--space-4);
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-5);
}

.steps li {
  position: relative;
  padding: var(--space-5);
  background: var(--c-bg-elevated);
  border-radius: var(--radius);
  box-shadow: var(--c-shadow-sm);
  border: 1px solid var(--c-border);
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-bottom: var(--space-3);
  border-radius: 50%;
  background: var(--c-primary);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
}

/* Calculator */
.calculator {
  margin: var(--space-5) 0 var(--space-6);
}

.calc-layout {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

.calc-main,
.result-card {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--c-shadow);
  padding: var(--space-5);
}

.calc-title {
  margin-top: 0;
}

.calc-controls {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.seg-control {
  display: inline-flex;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  padding: 3px;
  margin: 0;
  background: var(--c-primary-soft);
}

.seg-control legend {
  padding: 0;
}

.seg-option {
  cursor: pointer;
}

.seg-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg-option span {
  display: block;
  padding: 0.45rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  color: var(--c-text-muted);
}

.seg-option input:checked + span {
  background: var(--c-primary);
  color: #fff;
}

.seg-option input:focus-visible + span {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-2);
  font-size: 0.95rem;
}

.field select,
.field input,
.subject-table input,
.subject-table select,
.contact-form input,
.contact-form textarea,
.contact-form select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: var(--c-bg);
  color: var(--c-text);
  font: inherit;
}

.field select:focus,
.field input:focus,
.subject-table input:focus,
.subject-table select:focus,
.contact-form input:focus,
.contact-form textarea:focus {
  outline: 2px solid var(--c-primary);
  outline-offset: 1px;
  border-color: var(--c-primary);
}

.toggle-fourth {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-weight: 500;
  cursor: pointer;
}

.help-text {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  margin: calc(var(--space-2) * -1) 0 0;
}

.subject-table-wrap {
  overflow-x: auto;
  margin-bottom: var(--space-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}

.subject-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

.subject-table th,
.subject-table td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}

.subject-table th {
  background: var(--c-primary-soft);
  font-size: 0.9rem;
}

.subject-table tr:last-child td {
  border-bottom: 0;
}

.cell-fourth label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.cell-fourth .fourth-select {
  min-width: 5.5rem;
}

.calc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.65rem 1.15rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--c-primary-dark);
}

.btn-secondary {
  background: var(--c-primary-soft);
  color: var(--c-primary-dark);
  border-color: var(--c-border);
}

.btn-ghost {
  background: transparent;
  border-color: var(--c-border);
  color: var(--c-text-muted);
}

.btn-accent {
  background: var(--c-accent);
  color: #1a1408;
}

.btn-accent:hover {
  background: var(--c-accent-dark);
  color: #fff;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--c-danger);
}

.btn-icon:hover {
  background: var(--c-danger-bg);
}

.result-card {
  text-align: center;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}

.result-label {
  margin: 0;
  color: var(--c-text-muted);
  font-weight: 500;
}

.result-gpa {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 4rem);
  font-weight: 700;
  color: var(--c-primary);
  margin: var(--space-2) 0;
  line-height: 1;
  animation: gpaPop 0.35s ease;
}

@keyframes gpaPop {
  from { opacity: 0.4; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.result-letter {
  margin-bottom: var(--space-4);
}

.result-fail-banner {
  background: var(--c-danger-bg);
  color: var(--c-danger);
  font-weight: 700;
  padding: var(--space-3);
  border-radius: 8px;
  margin-bottom: var(--space-4);
}

.result-card.is-fail .result-gpa {
  color: var(--c-danger);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: var(--space-4) 0;
  border-top: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
}

.result-stats div {
  margin: 0;
}

.result-stats dt {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  margin: 0 0 var(--space-1);
}

.result-stats dd {
  margin: 0;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.result-msg {
  font-size: 0.9rem;
  color: var(--c-text-muted);
  min-height: 1.4em;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin-bottom: var(--space-5);
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
}

.grade-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-bg-elevated);
}

.grade-table th,
.grade-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
}

.grade-table th {
  background: var(--c-primary);
  color: #fff;
}

.grade-table tr:nth-child(even) td {
  background: var(--c-primary-soft);
}

.grade-table caption {
  text-align: left;
  padding: var(--space-3);
  font-weight: 600;
}

/* FAQ */
.faq-list {
  display: grid;
  gap: var(--space-3);
}

.faq-item {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--c-shadow-sm);
}

.faq-item summary {
  cursor: pointer;
  padding: var(--space-4) var(--space-5);
  font-weight: 600;
  font-family: var(--font-display);
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  float: right;
  color: var(--c-primary);
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-body {
  padding: 0 var(--space-5) var(--space-4);
  color: var(--c-text-muted);
}

/* English summary */
.english-summary {
  margin: var(--space-6) 0;
  padding: var(--space-5);
  background: var(--c-bg-elevated);
  border-left: 4px solid var(--c-accent);
  border-radius: var(--radius);
  box-shadow: var(--c-shadow-sm);
}

.english-summary code {
  background: var(--c-primary-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Related / blog */
.related-links {
  margin: var(--space-6) 0;
  padding: var(--space-5);
  background: var(--c-primary-soft);
  border-radius: var(--radius);
}

.related-links ul {
  margin: 0 0 var(--space-4);
  padding-left: 1.2rem;
}

.blog-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

.blog-card {
  background: var(--c-bg-elevated);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--c-shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.blog-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--c-shadow);
}

.blog-card a {
  text-decoration: none;
  color: inherit;
  display: block;
  padding: var(--space-5);
}

.blog-card h2 {
  font-size: 1.25rem;
  margin-bottom: var(--space-2);
  color: var(--c-primary);
}

.blog-meta {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  margin-bottom: var(--space-3);
}

.article-body {
  max-width: 42rem;
}

.article-body h2 {
  margin-top: var(--space-6);
}

/* Ads */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  margin: var(--space-4) 0;
  border: 1px dashed var(--c-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--c-bg) 80%, var(--c-border));
}

.ad-slot--side {
  min-height: 250px;
  margin-top: var(--space-4);
}

.ad-label {
  font-size: 0.8rem;
  color: var(--c-text-muted);
  letter-spacing: 0.04em;
}

/* Contact */
.contact-form {
  max-width: 32rem;
  display: grid;
  gap: var(--space-4);
}

.hp-field {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  overflow: hidden;
}

.alert {
  padding: var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
}

.alert-success {
  background: var(--c-primary-soft);
  border: 1px solid var(--c-primary);
  color: var(--c-primary-dark);
}

.alert-error {
  background: var(--c-danger-bg);
  border: 1px solid var(--c-danger);
  color: var(--c-danger);
}

/* Footer */
.site-footer {
  margin-top: var(--space-7);
  padding: var(--space-7) 0 var(--space-5);
  background: var(--c-bg-elevated);
  border-top: 1px solid var(--c-border);
}

.footer-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
}

.footer-heading {
  font-size: 1rem;
  margin-bottom: var(--space-3);
  color: var(--c-primary);
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-links li {
  margin-bottom: var(--space-2);
}

.footer-links a {
  text-decoration: none;
  color: var(--c-text-muted);
}

.footer-links a:hover {
  color: var(--c-primary);
}

.logo-footer {
  margin-bottom: var(--space-3);
  font-weight: 600;
}

.footer-brand p {
  color: var(--c-text-muted);
  font-size: 0.95rem;
}

.footer-bottom {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--c-border);
  font-size: 0.9rem;
  color: var(--c-text-muted);
}

.footer-note {
  margin: var(--space-2) 0 0;
  font-size: 0.85rem;
}

/* 404 */
.error-page {
  text-align: center;
  padding: var(--space-7) 0;
}

.error-page .code {
  font-family: var(--font-display);
  font-size: 5rem;
  color: var(--c-primary);
  line-height: 1;
  margin: 0;
}

/* Layout helpers */
.two-col {
  display: grid;
  gap: var(--space-5);
}

/* Responsive */
@media (min-width: 768px) {
  .calc-layout {
    grid-template-columns: 1.4fr 0.9fr;
    align-items: start;
  }

  .blog-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-grid {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
  }

  .steps {
    grid-template-columns: repeat(3, 1fr);
  }

  .two-col {
    grid-template-columns: 2fr 1fr;
  }
}

@media (min-width: 1280px) {
  :root {
    --max-w: 1200px;
  }
}

@media (max-width: 767px) {
  .nav-toggle {
    display: flex;
  }

  .site-nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--c-bg-elevated);
    border-bottom: 1px solid var(--c-border);
    padding: var(--space-3) var(--space-4) var(--space-4);
    display: none;
    box-shadow: var(--c-shadow);
  }

  .site-nav.is-open {
    display: block;
  }

  .nav-list {
    flex-direction: column;
  }

  .header-inner {
    position: relative;
  }

  .result-stats {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
