/*
Theme Name: TotalGrader Studio
Theme URI: https://totalgrader.com/
Author: TotalGrader
Author URI: https://totalgrader.com/
Description: A responsive, accessible WordPress theme for TotalGrader's grade calculators and education guides. Existing posts, pages, and calculator blocks remain editable in WordPress.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: totalgrader-studio
*/

:root {
  --tg-ink: #17243b;
  --tg-muted: #63718a;
  --tg-primary: #5146e5;
  --tg-primary-dark: #3e35c7;
  --tg-mint: #c9f4e7;
  --tg-green: #087b64;
  --tg-line: #e4e9f2;
  --tg-paper: #ffffff;
  --tg-canvas: #f5f7fc;
  --tg-soft-blue: #eef0ff;
  --tg-shadow: 0 18px 50px rgba(30, 45, 78, .08);
  --tg-radius: 20px;
  --tg-content: 1160px;
  --tg-reading: 790px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--tg-ink);
  background: var(--tg-canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; }
a { color: var(--tg-primary); text-decoration-thickness: .08em; text-underline-offset: .18em; }
a:hover { color: var(--tg-primary-dark); }
button, input, select, textarea { font: inherit; }
button, input[type="submit"], input[type="button"] { cursor: pointer; }
::selection { color: #fff; background: var(--tg-primary); }
:focus-visible { outline: 3px solid #8d86ff; outline-offset: 3px; }

.tg-shell { width: min(var(--tg-content), calc(100% - 40px)); margin-inline: auto; }
.screen-reader-text {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.screen-reader-text:focus {
  clip: auto; width: auto; height: auto; margin: 8px; padding: 12px 16px;
  color: #fff; background: var(--tg-ink); border-radius: 8px; z-index: 100000;
}
.skip-link {
  position: fixed; z-index: 100000; top: 10px; left: 10px; padding: 10px 14px;
  color: #fff; background: var(--tg-ink); transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

/* Header and navigation */
.site-header { position: relative; z-index: 20; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--tg-line); }
.header-inner {
  min-height: 82px; display: flex; align-items: center; justify-content: space-between;
  gap: 26px;
}
.site-branding { display: inline-flex; align-items: center; gap: 11px; flex: 0 0 auto; color: var(--tg-ink); text-decoration: none; }
.site-branding:hover { color: var(--tg-ink); }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 42px;
  color: #fff; background: var(--tg-primary); border-radius: 14px;
  box-shadow: 0 7px 16px rgba(81, 70, 229, .22);
}
.brand-mark svg { width: 25px; height: 25px; }
.brand-name { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.055em; line-height: 1.08; }
.brand-name span { color: var(--tg-primary); }
.brand-tagline { display: block; margin-top: 4px; color: var(--tg-muted); font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.custom-logo-link { display: flex; align-items: center; }
.custom-logo { width: auto; max-height: 48px; }
.menu-toggle {
  display: none; align-items: center; justify-content: center; width: 44px; height: 44px;
  color: var(--tg-ink); background: #fff; border: 1px solid var(--tg-line); border-radius: 12px;
}
.menu-toggle svg { width: 21px; height: 21px; }
.primary-navigation { display: flex; align-items: center; gap: 27px; }
.primary-navigation ul { display: flex; align-items: center; gap: 24px; margin: 0; padding: 0; list-style: none; }
.primary-navigation li { position: relative; }
.primary-navigation a {
  display: inline-flex; align-items: center; min-height: 42px; color: #43506a; font-size: 14px;
  font-weight: 650; text-decoration: none; transition: color .18s ease;
}
.primary-navigation a:hover, .primary-navigation .current-menu-item > a,
.primary-navigation .current_page_item > a { color: var(--tg-primary); }
.primary-navigation .sub-menu {
  position: absolute; top: calc(100% + 6px); left: -16px; z-index: 25; display: none;
  min-width: 220px; padding: 9px; background: #fff; border: 1px solid var(--tg-line);
  border-radius: 14px; box-shadow: var(--tg-shadow);
}
.primary-navigation li:hover > .sub-menu, .primary-navigation li:focus-within > .sub-menu { display: block; }
.primary-navigation .sub-menu a { width: 100%; padding: 8px 10px; border-radius: 8px; }
.primary-navigation .sub-menu a:hover { background: var(--tg-canvas); }
.header-search { display: flex; align-items: center; gap: 7px; }
.header-search input[type="search"] {
  width: 154px; height: 39px; padding: 0 12px; color: var(--tg-ink); background: var(--tg-canvas);
  border: 1px solid transparent; border-radius: 11px; font-size: 13px;
}
.header-search input[type="search"]:focus { background: #fff; border-color: #aaa5ff; outline: none; }
.header-search button {
  width: 39px; height: 39px; display: grid; place-items: center; padding: 0; color: #fff;
  background: var(--tg-primary); border: 0; border-radius: 11px;
}
.header-search button:hover { background: var(--tg-primary-dark); }
.header-search svg { width: 17px; height: 17px; }
.primary-navigation .header-search { flex: 0 0 auto; }
.primary-navigation .header-search .search-form { display: flex; width: 228px; gap: 6px; }
.primary-navigation .header-search .search-form label { min-width: 0; flex: 1; }
.primary-navigation .header-search .search-field { width: 100%; min-height: 39px; padding: 0 11px; background: var(--tg-canvas); border: 1px solid transparent; border-radius: 10px; font-size: 12px; }
.primary-navigation .header-search .search-submit { min-height: 39px; padding: 0 12px; color: #fff; background: var(--tg-primary); border: 0; border-radius: 10px; font-size: 12px; font-weight: 700; }
.primary-navigation .header-search .search-submit:hover { background: var(--tg-primary-dark); }

/* Main content surfaces */
.site-main { min-height: 62vh; padding: 34px 0 76px; }
.front-page, .page-surface, .archive-surface, .search-surface, .error-surface {
  padding: clamp(24px, 4vw, 52px); background: var(--tg-paper); border: 1px solid #edf0f6;
  border-radius: var(--tg-radius); box-shadow: 0 10px 36px rgba(30, 45, 78, .035);
}
.front-page { padding: clamp(20px, 3.7vw, 48px); }
.page-surface { max-width: 980px; margin-inline: auto; }
.page-heading, .archive-heading { margin-bottom: 30px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 11px; color: var(--tg-green);
  font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
}
.eyebrow::before { width: 8px; height: 8px; content: ""; background: #19b88b; border-radius: 50%; }
h1, h2, h3, h4, h5, h6 { color: var(--tg-ink); font-weight: 750; letter-spacing: -.035em; line-height: 1.2; }
h1 { margin: 0 0 18px; font-size: clamp(2rem, 4.5vw, 3.35rem); }
h2 { margin: 1.7em 0 .65em; font-size: clamp(1.45rem, 2.7vw, 2rem); }
h3 { margin: 1.45em 0 .55em; font-size: clamp(1.18rem, 2vw, 1.45rem); }
h4 { margin: 1.25em 0 .5em; font-size: 1.12rem; }
p { margin: 0 0 1.15em; }
.entry-content { min-width: 0; color: #35425a; }
.entry-content > :first-child { margin-top: 0; }
.entry-content h2, .entry-content h3, .entry-content h4 { scroll-margin-top: 100px; }
.entry-content ul, .entry-content ol { padding-left: 1.35em; margin: 0 0 1.25em; }
.entry-content li { padding-left: .2em; margin: .32em 0; }
.entry-content blockquote {
  margin: 1.7em 0; padding: 18px 22px; color: #44516a; background: var(--tg-soft-blue);
  border-left: 4px solid var(--tg-primary); border-radius: 0 14px 14px 0;
}
.entry-content hr { height: 1px; margin: 2.5em 0; background: var(--tg-line); border: 0; }
.entry-content img { border-radius: 15px; }
.entry-content figure { margin: 1.5em 0; }
.entry-content figcaption { margin-top: 8px; color: var(--tg-muted); font-size: 13px; text-align: center; }
.entry-content table {
  width: 100%; margin: 1.4em 0 1.8em; border-collapse: separate; border-spacing: 0; overflow: hidden;
  border: 1px solid var(--tg-line); border-radius: 13px; font-size: .94em;
}
.entry-content th, .entry-content td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--tg-line); }
.entry-content th { color: var(--tg-ink); background: #f4f5ff; font-weight: 750; }
.entry-content tr:last-child td { border-bottom: 0; }
.entry-content code, .entry-content pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.entry-content code { padding: .12em .38em; color: #4138b4; background: #f0efff; border-radius: 5px; }
.entry-content pre { overflow-x: auto; padding: 18px; background: #17243b; color: #fff; border-radius: 12px; }
.entry-content pre code { padding: 0; color: inherit; background: transparent; }
.entry-content input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
.entry-content select, .entry-content textarea {
  max-width: 100%; padding: 11px 13px; color: var(--tg-ink); background: #fff;
  border: 1px solid #d9dfeb; border-radius: 10px;
}
.entry-content input[type="submit"], .entry-content button, .wp-block-button__link {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px;
  color: #fff; background: var(--tg-primary); border: 0; border-radius: 11px; font-weight: 750;
  text-decoration: none; transition: background .18s ease, transform .18s ease;
}
.entry-content input[type="submit"]:hover, .entry-content button:hover, .wp-block-button__link:hover {
  color: #fff; background: var(--tg-primary-dark); transform: translateY(-1px);
}
.entry-content .wp-block-button { margin: 1.25em 0; }
.entry-content .wp-block-separator { border-color: var(--tg-line); }
.entry-content .wp-block-columns { gap: 22px; }
.entry-content .wp-block-image img { height: auto; }
.entry-content .wp-block-embed { max-width: 100%; }

/* Calculator and tool content, including common plugin/block class names */
.entry-content .calculator, .entry-content .grade-calculator, .entry-content .grade-calculator-container,
.entry-content .calculator-container, .entry-content .tool-card, .entry-content .tool-box,
.entry-content .tg-calculator {
  padding: clamp(19px, 3vw, 32px); background: linear-gradient(145deg, #f3f3ff, #f5fffb);
  border: 1px solid #e4e6ff; border-radius: 20px;
}
.entry-content label { color: var(--tg-ink); font-weight: 650; }
.entry-content input[type="number"], .entry-content input[type="text"], .entry-content input[type="email"] {
  min-height: 45px;
}
.entry-content .result, .entry-content .result-box, .entry-content .grade-result {
  padding: 15px 18px; background: #e9fbf4; border: 1px solid #c7f0e1; border-radius: 13px;
}
.entry-content details { margin: 1em 0; padding: 14px 18px; background: #f7f8fc; border-radius: 12px; }
.entry-content summary { color: var(--tg-ink); font-weight: 700; cursor: pointer; }

/* Guide cards and article layouts */
.latest-guides { margin-top: 48px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; }
.section-heading p { margin: 7px 0 0; color: var(--tg-muted); }
.text-link { font-size: 14px; font-weight: 750; white-space: nowrap; }
.post-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.post-card {
  min-width: 0; overflow: hidden; background: #fff; border: 1px solid var(--tg-line); border-radius: 17px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.post-card:hover { transform: translateY(-3px); box-shadow: var(--tg-shadow); }
.post-card-image { display: block; overflow: hidden; aspect-ratio: 16/9; background: var(--tg-soft-blue); }
.post-card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.post-card:hover .post-card-image img { transform: scale(1.035); }
.post-card-image--empty { display: grid; place-items: center; color: var(--tg-primary); }
.post-card-image--empty svg { width: 45px; height: 45px; opacity: .6; }
.post-card-body { padding: 17px 18px 19px; }
.post-card-category { display: block; margin-bottom: 8px; color: var(--tg-green); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.post-card-title { margin: 0 0 9px; font-size: 1.12rem; line-height: 1.35; }
.post-card-title a { color: var(--tg-ink); text-decoration: none; }
.post-card-title a:hover { color: var(--tg-primary); }
.post-card-excerpt { margin: 0; color: var(--tg-muted); font-size: 13px; line-height: 1.6; }
.post-card-meta { margin-top: 13px; color: var(--tg-muted); font-size: 12px; }

.article-layout { display: grid; grid-template-columns: minmax(0, 790px) minmax(220px, 280px); align-items: start; gap: 32px; }
.article-main, .sidebar-card { background: #fff; border: 1px solid #edf0f6; border-radius: var(--tg-radius); }
.article-main { overflow: hidden; }
.article-header { padding: clamp(24px, 4vw, 48px) clamp(22px, 4vw, 52px) 20px; }
.article-header h1 { margin: 9px 0 14px; font-size: clamp(2rem, 4vw, 3rem); }
.article-categories { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.article-categories a {
  padding: 5px 10px; color: var(--tg-green); background: #eaf9f3; border-radius: 999px;
  font-size: 11px; font-weight: 800; text-decoration: none;
}
.article-deck { margin: 0 0 18px; color: var(--tg-muted); font-size: 1.08rem; }
.article-meta { display: flex; flex-wrap: wrap; gap: 9px 17px; color: var(--tg-muted); font-size: 12px; }
.article-meta a { color: inherit; }
.article-featured { margin: 0 30px 23px; overflow: hidden; border-radius: 15px; background: var(--tg-soft-blue); }
.article-featured img { display: block; width: 100%; max-height: 470px; object-fit: cover; }
.article-content { padding: 0 clamp(22px, 4vw, 52px) 42px; }
.article-content .entry-content { font-size: 17px; line-height: 1.82; }
.article-content .entry-content h2 { margin-top: 1.75em; }
.article-sidebar { display: grid; gap: 17px; }
.sidebar-card { padding: 21px; }
.sidebar-card h2 { margin: 0 0 14px; font-size: 1.12rem; }
.sidebar-links { margin: 0; padding: 0; list-style: none; }
.sidebar-links li + li { border-top: 1px solid var(--tg-line); }
.sidebar-links a { display: block; padding: 10px 0; color: #38455c; font-size: 13px; font-weight: 650; text-decoration: none; }
.sidebar-links a:hover { color: var(--tg-primary); }
.sidebar-card .widget { margin-bottom: 22px; }
.sidebar-card .widget:last-child { margin-bottom: 0; }
.post-navigation { display: flex; justify-content: space-between; gap: 20px; padding: 20px 0; border-top: 1px solid var(--tg-line); }
.post-navigation a { max-width: 48%; font-weight: 700; text-decoration: none; }
.post-navigation .nav-next { margin-left: auto; text-align: right; }

/* Archives and search */
.archive-surface, .search-surface { min-height: 300px; }
.archive-heading h1, .search-heading h1 { margin-bottom: 9px; }
.archive-description { max-width: 740px; color: var(--tg-muted); }
.archive-description > :last-child { margin-bottom: 0; }
.archive-tools { margin: 22px 0 26px; padding: 20px; background: #f6f7ff; border-radius: 15px; }
.archive-tools h2 { margin: 0 0 12px; font-size: 1.05rem; }
.category-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.category-chips a { padding: 7px 12px; color: #443db8; background: #fff; border: 1px solid #e2e0ff; border-radius: 999px; font-size: 12px; font-weight: 700; text-decoration: none; }
.pagination, .nav-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 30px; }
.page-numbers {
  display: grid; place-items: center; min-width: 40px; min-height: 40px; padding: 0 12px;
  color: #48556c; background: #fff; border: 1px solid var(--tg-line); border-radius: 10px; text-decoration: none;
}
.page-numbers.current, .page-numbers:hover { color: #fff; background: var(--tg-primary); border-color: var(--tg-primary); }
.search-form { display: flex; max-width: 600px; gap: 9px; }
.search-form label { flex: 1; }
.search-form .search-field {
  width: 100%; min-height: 47px; padding: 10px 14px; color: var(--tg-ink); background: #fff;
  border: 1px solid #d9dfeb; border-radius: 11px;
}
.search-form .search-submit {
  min-height: 47px; padding: 0 20px; color: #fff; background: var(--tg-primary);
  border: 0; border-radius: 11px; font-weight: 750;
}
.search-form .search-submit:hover { background: var(--tg-primary-dark); }
.search-result-list { display: grid; gap: 13px; margin-top: 28px; }
.search-result { padding: 18px 20px; background: #fff; border: 1px solid var(--tg-line); border-radius: 14px; }
.search-result h2 { margin: 0 0 6px; font-size: 1.2rem; }
.search-result h2 a { color: var(--tg-ink); text-decoration: none; }
.search-result p { margin: 0; color: var(--tg-muted); font-size: 14px; }
.empty-state { padding: 32px; text-align: center; background: #f7f8fc; border-radius: 15px; }
.empty-state h2 { margin-top: 0; }

/* Footer */
.site-footer { color: #d9e1f2; background: #17243b; }
.footer-main { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 44px; padding-top: 52px; padding-bottom: 42px; }
.footer-brand .site-branding { color: #fff; }
.footer-brand .custom-logo-link { padding: 6px 10px; background: #fff; border-radius: 9px; }
.footer-brand .custom-logo { max-height: 38px; }
.footer-brand .brand-tagline { color: #aebbd1; }
.footer-brand .brand-mark { color: var(--tg-ink); background: var(--tg-mint); box-shadow: none; }
.footer-description { max-width: 350px; margin: 15px 0 0; color: #b8c4d8; font-size: 14px; }
.footer-column h2 { margin: 3px 0 15px; color: #fff; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.footer-menu, .footer-policy-links { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.footer-menu a, .footer-policy-links a { color: #c0cbe0; font-size: 13px; text-decoration: none; }
.footer-menu a:hover, .footer-policy-links a:hover { color: #fff; text-decoration: underline; }
.footer-bottom { display: flex; justify-content: space-between; gap: 20px; padding-top: 17px; padding-bottom: 20px; color: #aebbd1; border-top: 1px solid rgba(255,255,255,.13); font-size: 12px; }
.footer-bottom p { margin: 0; }

/* WordPress defaults and small screens */
.alignwide { max-width: 1100px; margin-left: auto; margin-right: auto; }
.alignfull { width: 100%; max-width: none; margin-left: 0; margin-right: 0; }
.wp-caption { max-width: 100%; }
.gallery { display: grid; gap: 14px; }
.comment-respond, .comments-area { margin-top: 32px; }
.comment-list { padding-left: 1.3em; }
.comment-body { padding: 15px 0; border-bottom: 1px solid var(--tg-line); }
.comment-form input:not([type="checkbox"]), .comment-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--tg-line); border-radius: 9px; }
.comment-form .submit { width: auto; color: #fff; background: var(--tg-primary); border: 0; border-radius: 10px; padding: 11px 17px; font-weight: 700; }

@media (max-width: 980px) {
  .header-inner { flex-wrap: wrap; min-height: 74px; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
  .menu-toggle { display: inline-flex; margin-left: auto; }
  .primary-navigation { order: 3; width: 100%; align-items: stretch; flex-direction: column; gap: 14px; }
  .primary-navigation.is-collapsed { display: none; }
  .primary-navigation ul { align-items: stretch; flex-direction: column; gap: 0; }
  .primary-navigation a { width: 100%; min-height: 43px; }
  .primary-navigation .sub-menu { position: static; display: block; min-width: 0; padding: 0 0 0 14px; border: 0; box-shadow: none; }
  .header-search { width: 100%; }
  .primary-navigation .header-search .search-form { width: 100%; max-width: none; }
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .article-sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  body { font-size: 15px; }
  .tg-shell { width: min(100% - 24px, var(--tg-content)); }
  .site-main { padding: 17px 0 48px; }
  .front-page, .page-surface, .archive-surface, .search-surface, .error-surface { padding: 22px 18px; border-radius: 16px; }
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .post-card-body { padding: 13px; }
  .post-card-title { font-size: 1rem; }
  .post-card-excerpt { font-size: 12px; }
  .article-sidebar { grid-template-columns: 1fr; }
  .article-featured { margin: 0 16px 20px; }
  .article-header { padding: 24px 20px 17px; }
  .article-content { padding: 0 20px 30px; }
  .article-content .entry-content { font-size: 16px; }
  .entry-content table { display: block; overflow-x: auto; white-space: nowrap; }
  .footer-main { grid-template-columns: 1fr 1fr; gap: 28px 22px; padding-top: 36px; }
  .footer-brand { grid-column: 1 / -1; }
  .footer-bottom { flex-direction: column; gap: 6px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
}
@media (max-width: 480px) {
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; border-radius: 12px; }
  .brand-name { font-size: 18px; }
  .brand-tagline { font-size: 9px; }
  .post-grid { grid-template-columns: 1fr; }
  .post-card { display: grid; grid-template-columns: 110px minmax(0, 1fr); }
  .post-card-image { height: 100%; min-height: 138px; aspect-ratio: auto; }
  .post-card-body { align-self: center; }
  .post-card-excerpt { display: none; }
  .footer-main { grid-template-columns: 1fr 1fr; }
  .search-form { flex-direction: column; }
  .search-form .search-submit { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
