/* ===========================================================================
   Science Papers – Global Styles (v12)
   • Button & Footer styling restored
   • Login modal centered via flex, no transforms
   • Removes page scroll when modal open
   • Grid gaps 2rem, equal‑height flex cards, shimmer, index, etc.
   ========================================================================== */

/* ---- Root Variables ---- */
:root {
  --radius: 8px;
  --blur: blur(12px);
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12);

  --green-500: #46c26d;
  --green-600: #36a95a;
  --green-700: #2c8d4b;
  --green-100: #e8fce8;
  --green-050: #f4fff4;

  --danger-600: #d62828;
  --text-strong: #000;
  --text-muted: #444;
  --border-light: #c8f5c8;

  --header-h: 60px;

  --shimmer-base: #f4fff4;
  --shimmer-mid: #e0ffe0;
  --shimmer-glow: #c8f5c8;

  /* Minimum card heights */
  --sp-card-minh-sm: 160px;
  --sp-card-minh-md: 190px;
  --sp-card-minh-lg: 210px;

  /* Grid gaps */
  --sp-card-row-gap: 2rem;
  --sp-card-col-gap: 2rem;
}

/* ---- Base / Reset ---- */
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
  background: #fff; color: var(--text-strong);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg {
  display: block; max-width: 100%; height: auto;
}
a {
  color: var(--green-600); text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
:is(button, input, select, textarea) {
  font-family: inherit; font-size: 100%;
}

/* ---- Layout Wrappers ---- */
.sp-header-inner,
.sp-main,
.sp-hero-content,
.sp-section {
  max-width: 1180px; margin-inline: auto; padding-inline: 1rem;
}
.sp-main { padding-block: 3rem; }
.sp-section { padding-block: 3rem; }
.sp-hero-content { padding-block: 4rem; padding-inline: 2rem; }

/* ---- Global Titles ---- */
.sp-page-title,
.sp-section-title {
  font-size: 1.8rem; margin-bottom: .75rem; font-weight: 600; text-align: center;
}

/* ===========================================================================
   Header
   ========================================================================== */
.sp-header {
  position: sticky; top: 0; z-index: 100; width: 100%;
  background: rgba(255,255,255,.64);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.sp-header-inner {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
}
.sp-site-title {
  margin: 0; font-size: 1.4rem; font-weight: 700;
}
.sp-site-title a {
  color: inherit; text-decoration: none;
}
.sp-nav {
  display: flex; gap: .5rem; align-items: center;
}

/* ===========================================================================
   Hero Section (index.html)
   ========================================================================== */
.sp-hero {
  display: grid; place-items: center;
  min-height: calc(100vh - var(--header-h) - 160px);
  padding: 4rem 1rem 3rem; text-align: center;
}
.sp-hero-content {
  width: 100%; max-width: 720px;
  background: rgba(255,255,255,.64);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.sp-hero-content h2 {
  margin: 0 0 1rem; font-size: clamp(2rem,5vw,3rem);
}
.sp-hero-content p {
  margin: 0 0 2rem; color: var(--text-muted); line-height: 1.5;
}

/* ---- Quick Subjects (index.html) ---- */
.sp-subjects {
  margin-top: 3rem;
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(120px,1fr));
}
.sp-subject {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  padding: 1rem;
  background: rgba(255,255,255,.64);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
  text-align: center;
}
.sp-subject:hover {
  transform: translateY(-2px); box-shadow: var(--shadow-lg);
}
.sp-subject-icon {
  font-size: 1.8rem; line-height: 1;
}
.sp-subject-label {
  font-size: .95rem; font-weight: 600; color: var(--text-strong);
}

/* ---- Stats Strip (index.html) ---- */
.sp-stats-strip {
  margin-top: 3rem; background: var(--green-050); padding: 2rem 1rem;
}
.sp-stats {
  max-width: 800px; margin-inline: auto;
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(160px,1fr));
  text-align: center;
}
.sp-stat-num {
  font-size: 1.75rem; font-weight: 700; color: var(--green-600);
  margin-bottom: .25rem;
}
.sp-stat-label {
  font-size: .95rem; color: var(--text-muted);
}

/* ===========================================================================
   Features & Testimonials (index.html)
   ========================================================================== */
.sp-feature-grid {
  display: grid; gap: 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
}
.sp-feature-card {
  background: rgba(255,255,255,.64);
  backdrop-filter: var(--blur);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem; text-align: center;
  transition: transform .18s ease, box-shadow .18s ease;
  border: 1px solid var(--border-light);
}
.sp-feature-card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow-lg);
}
.sp-feature-card h3 {
  margin: 0 0 .5rem; font-size: 1.1rem;
}
.sp-feature-card p {
  margin: 0; color: var(--text-muted); font-size: .95rem; line-height: 1.4;
}
.sp-ic {
  width: 32px; height: 32px; margin-inline: auto; display: block;
}
.sp-ic svg {
  width: 100%; height: 100%; display: block;
}

/* Testimonials */
.sp-testimonials {
  background: var(--green-050); padding-block: 3rem;
}
.sp-testimonial-list {
  max-width: 900px; margin-inline: auto;
  display: grid; gap: 1.5rem; padding-inline: 1rem;
}
.sp-testimonial {
  background: rgba(255,255,255,.64);
  backdrop-filter: var(--blur);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem; border: 1px solid var(--border-light);
  position: relative; font-size: 1rem; line-height: 1.4;
}
.sp-testimonial::before {
  content:'“'; position: absolute; top: -8px; left: 8px;
  font-size: 3rem; color: var(--green-600); line-height: 1;
}
.sp-testimonial cite {
  display: block; margin-top: 1rem;
  font-style: normal; font-weight: 600; color: var(--text-muted);
  text-align: right;
}

/* ===========================================================================
   Resources/Games Grid (resources.html)
   ========================================================================== */
.sp-card-grid {
  display: grid;
  row-gap: var(--sp-card-row-gap);
  column-gap: var(--sp-card-col-gap);
  grid-template-columns: repeat(auto-fill, minmax(170px,1fr));
  align-items: stretch;
  grid-auto-rows: minmax(var(--sp-card-minh-sm), auto);
}
@media (min-width:600px) {
  .sp-card-grid {
    grid-auto-rows: minmax(var(--sp-card-minh-md), auto);
  }
}
@media (min-width:1080px) {
  .sp-card-grid {
    grid-template-columns: repeat(6,1fr);
    grid-auto-rows: minmax(var(--sp-card-minh-lg), auto);
  }
}

/* Cards */
.sp-card {
  position: relative; height: 100%;
  background: rgba(255,255,255,.64);
  backdrop-filter: var(--blur);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .75rem .9rem .35rem .9rem;
  text-align: center;
  transition: transform .18s ease, box-shadow .18s ease;
  border: 1px solid var(--border-light);
  display: flex; flex-direction: column; align-items: center;
}
.sp-card:hover,
.sp-card:focus-within {
  transform: translateY(-4px); box-shadow: var(--shadow-lg);
}

/* Image wrapper */
.sp-card-imgwrap {
  width: 100%; position: relative;
}
.sp-card-imgwrap::before {
  content: ''; display: block; padding-top: 100%;
}
.sp-card-imgwrap img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; border-radius: var(--radius);
}

/* Title */
.sp-card-title {
  margin-top: .4rem; margin-bottom: .4rem;
  font-size: .95rem; font-weight: 600;
  color: var(--text-strong);
  padding-inline: .25rem; word-break: break-word;
  line-height: 1.2;
}

/* Shimmer Loader */
.sp-card.is-loading::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg,
    var(--shimmer-base) 0%, var(--shimmer-mid) 35%,
    var(--shimmer-glow) 50%, var(--shimmer-mid) 65%,
    var(--shimmer-base) 100%);
  background-size: 200% 100%;
  animation: sp-shimmer 1.25s linear infinite;
  border-radius: var(--radius); opacity: .9; pointer-events: none;
}
@keyframes sp-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Click Overlay */
.sp-card-link {
  position: absolute; inset: 0;
  text-indent: -9999px; overflow: hidden;
  cursor: pointer;
}

/* Skeleton Tiles */
.sp-skel-card {
  position: relative; height: 100%;
  background: var(--shimmer-base);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}
.sp-skel-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg,
    var(--shimmer-base) 0%, var(--shimmer-mid) 35%,
    var(--shimmer-glow) 50%, var(--shimmer-mid) 65%,
    var(--shimmer-base) 100%);
  background-size: 200% 100%; animation: sp-shimmer 1.25s linear infinite;
  opacity: .9;
}

/* ===========================================================================
   Buttons
   ========================================================================== */
.sp-btn,
.sp-btn-primary,
.btn,
button {
  padding: .8rem 1.4rem;
  font-size: .95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  color: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.sp-btn:hover,
.sp-btn-primary:hover,
.btn:hover,
button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.sp-btn:active,
.sp-btn-primary:active,
.btn:active,
button:active {
  transform: none;
}

.sp-btn-ghost,
.sp-btn-ghost-small {
  background: rgba(255,255,255,.64);
  color: var(--green-600);
  border: 1px solid var(--border-light);
  padding: .6rem 1.2rem;
}
.sp-btn-ghost-small {
  font-size: .85rem; padding: .45rem .9rem;
}
.sp-btn-ghost:hover,
.sp-btn-ghost-small:hover {
  background: var(--green-600); color: #fff;
}

.sp-btn-danger-small {
  background: var(--danger-600); color: #fff;
  padding: .45rem .9rem; font-size: .85rem;
}
.sp-btn-danger-small:hover {
  filter: brightness(1.1);
}

/* ===========================================================================
   Footer
   ========================================================================== */
.sp-footer {
  text-align: center;
  padding: 3rem 1rem;
  font-size: .875rem;
  color: var(--text-muted);
}

/* ===========================================================================
   Modal (resources.html)
   ========================================================================== */
.sp-modal {
  display: none;
}
.sp-modal[open] {
  display: flex;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  padding: 0;
  margin: 0;
}
body[aria-hidden] {
  overflow: hidden; /* prevent body scroll when modal open if you add aria-hidden */
}
.sp-modal-content {
  width: min(380px, 90vw);
  max-width: 380px;
  box-sizing: border-box;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(255,255,255,0.95);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sp-modal-content h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
}
.sp-modal-desc {
  margin: 0;
  font-size: .95rem;
  color: var(--text-muted);
  text-align: center;
}
.sp-field {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .95rem;
  width: 100%;
}
.sp-field span {
  font-weight: 600;
  color: var(--text-strong);
}
.sp-field input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: .75rem 1rem;
  font-size: 1rem;
  line-height: 1.2;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--text-strong);
}
.sp-modal-actions {
  display: flex;
  justify-content: center;
  gap: .75rem;
  padding-top: .5rem;
  width: 100%;
}

/* ===========================================================================
   Toasts
   ========================================================================== */
.sp-toast-container {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  display: grid;
  gap: .5rem;
  z-index: 200;
}
.sp-toast {
  padding: .7rem 1.25rem;
  border-radius: var(--radius);
  background: var(--green-600);
  color: #fff;
  font-size: .95rem;
  animation:
    sp-toast-in .2s ease forwards,
    sp-toast-out .2s ease 4s forwards;
}
.sp-toast-error {
  background: var(--danger-600);
}
@keyframes sp-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sp-toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

/* ===========================================================================
   Material Page (material.html)
   ========================================================================== */
.sp-header-material {
  display: none;
}
.sp-material-back,
.sp-material-controls {
  position: fixed;
  z-index: 250;
  pointer-events: auto;
}
.sp-material-back {
  top: .75rem; left: .75rem;
}
.sp-material-controls {
  top: .75rem; right: .75rem;
  display: flex; gap: .5rem;
}
.sp-material-wrapper {
  position: fixed; inset: 0; overflow: hidden;
}
.sp-material-wrapper iframe {
  width: 100%; height: 100%; border: none; background: #000; display: block;
}
body[data-page="material"] {
  overflow: hidden;
}







/* ===========================================================================
   Login Page: Improved Styling + Back‑Button
   ========================================================================== */
body[data-page="login"] {
  background: var(--green-050);
}
.sp-header {
  background: rgba(255,255,255,.9);
}
#loginForm {
  padding: 3rem 2rem;
}
#loginForm .sp-page-title {
  color: var(--green-700);
  margin-bottom: 2rem;
}
#loginForm .sp-field {
  margin-bottom: 1.25rem;
}
#loginForm .sp-field span {
  font-size: 1rem;
}
#loginForm .sp-field input {
  padding: .9rem 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}
#loginForm .sp-field input:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(54,169,90, .25);
}

#loginForm .sp-modal-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}
#loginForm .sp-modal-actions .sp-btn-primary {
  flex: 1;
}
#loginForm .sp-modal-actions .sp-btn-ghost-small,
#loginForm .sp-modal-actions .sp-btn-ghost {
  background: transparent;
  color: var(--green-600);
  border: 2px solid var(--green-600);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  text-decoration: none;
  text-align: center;
  flex-shrink: 0;
}
#loginForm .sp-modal-actions .sp-btn-ghost:hover {
  background: var(--green-600);
  color: #fff;
}

footer.sp-footer {
  background: transparent;
  color: var(--text-muted);
  padding-block: 1rem;
}


/* ---------------------------------------------------------------------------
   Login Page: Terms note under the buttons
   ------------------------------------------------------------------------- */
body[data-page="login"] .sp-terms {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 1rem;
  line-height: 1.4;
}

body[data-page="login"] .sp-terms a {
  color: var(--green-600);
  text-decoration: underline;
}

body[data-page="login"] .sp-terms a:hover {
  color: var(--green-700);
}


/* ===========================================================================
   Terms of Service Page: list & heading styling
   ========================================================================== */
body[data-page="terms"] .tos-list {
  list-style: disc;
  margin: 1rem 0 1rem 1.5rem;
  color: var(--text-muted);
}
body[data-page="terms"] .tos-list li {
  margin-bottom: .5rem;
  line-height: 1.4;
}
body[data-page="terms"] h3 {
  margin-top: 1.5rem;
  font-size: 1.1rem;
  color: var(--green-700);
}
/* ===========================================================================
   Terms of Service Page: list & heading styling
   ========================================================================== */
body[data-page="terms"] .tos-list {
  list-style: disc;
  margin: 1rem 0 1rem 1.5rem;
  color: var(--text-muted);
}
body[data-page="terms"] .tos-list li {
  margin-bottom: .5rem;
  line-height: 1.4;
}
body[data-page="terms"] h3 {
  margin-top: 1.5rem;
  font-size: 1.1rem;
  color: var(--green-700);
}


/* ---------------------------------------------------------------------------
   Resources Page: Search Bar
   ------------------------------------------------------------------------- */
.sp-search-wrap {
  max-width: 600px;
  margin: 2rem auto 1.5rem;
  padding-inline: 1rem;
}
#searchInput {
  width: 100%;
  box-sizing: border-box;
  padding: .75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: rgba(255,255,255,.9);
  transition: border-color .2s, box-shadow .2s;
}
#searchInput:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(54,169,90,.25);
}
