/*
 * Pennacool Interschool Competition Stylesheet
 * Organized for readability and updated to strictly use CSS variables for colors.
 */

/* ==========================================================================
   0. Base Imports & Global Styles
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Nunito:wght@400;600;800&display=swap');

html {
  scroll-behavior: smooth;
}

/* ==========================================================================
   1. Root Variables (Color Palette, Shadows, Radius)
   ========================================================================== */

:root {
  /* Kid-friendly Color Palette */
  /* Primary Colors */
  --color-sky: #64B5F6;       /* Bright Sky Blue */
  --color-sunshine: #FFD54F;  /* Cheerful Yellow */
  --color-grass: #81C784;     /* Fresh Green */
  --color-candy: #FF8A80;     /* Soft Coral */
  --color-grape: #B39DDB;     /* Gentle Purple */

  /* Light Tints */
  --color-sky-light: #90CAF9;
  --color-sunshine-light: #FFE082;
  --color-grass-light: #A5D6A7;
  --color-candy-light: #FFAB91;
  --color-grape-light: #D1C4E9;

  /* Background Shades */
  --color-cloud: #F5F7FA;     /* Off-white background */
  --color-mist: #E3F2FD;      /* Very light blue */
  --color-sand: #FFF8E1;      /* Soft cream */

  /* Aliases for 'Flow' colors - useful for theming */
  --flow-yellow: var(--color-sunshine);
  --flow-blue: var(--color-sky);
  --flow-cyan: var(--color-sky-light);
  --flow-red: var(--color-candy);
  --flow-gray: var(--color-cloud);

  /* Extra playful tints */
  --flow-yellow-200: #FFF6A6;
  --flow-blue-200: #D7E4FF;
  --flow-cyan-200: #CFF3FF;
  --flow-red-200: #FFD9CF;

  /* Text Colors */
  --text-primary: #102132;   /* main body text (soft black/dark navy) */
  --text-heading: #0B2E63;   /* headlines (cheery navy) */
  --text-secondary: #28425E; /* subheads / labels (muted blue-grey) */
  --text-muted: #5F7B95;     /* helper copy (lighter blue-grey) */
  --link: #164A9D;           /* brand blue */
  --link-hover: #2FC5F4;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
  --shadow-bounce: 0 14px 24px rgba(0,0,0,.12);

  /* Border Radii */
  --radius-xl: 1.25rem;
  --radius-2xl: 1.75rem;
  --radius-3xl: 2rem;
  --radius-pill: 999px;
}

/* ==========================================================================
   2. Typography
   ========================================================================== */

body {
  font-family: "Nunito", "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary);
  font-size: 18px;
  line-height: 1.6;
}

h1, h2, h3, h4, h5 {
  font-family: "Fredoka", "Nunito", "Poppins", system-ui, sans-serif;
  letter-spacing: .2px;
  color: var(--text-heading);
}

h2, h3 {
  font-weight: 700;
}

.lead, .small, .text-muted {
  color: var(--text-muted) !important;
}

a {
  color: var(--link);
  text-underline-offset: 2px;
}

a:hover, a:focus {
  color: var(--link-hover);
  text-decoration: underline;
}

/* ==========================================================================
   3. Body & Background
   ========================================================================== */

body {
  background: var(--flow-gray);
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("https://sea.pennacool.com/pennacool/images/isc_bg.png") center/cover no-repeat fixed;
  filter: saturate(1.05);
  opacity: .45;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(12px 12px at 12% 8%, color-mix(in srgb, var(--flow-yellow) 12%, transparent) 0 50%, transparent 52%) no-repeat,
    radial-gradient(14px 14px at 82% 18%, color-mix(in srgb, var(--flow-cyan) 12%, transparent) 0 50%, transparent 52%) no-repeat,
    radial-gradient(10px 10px at 25% 85%, color-mix(in srgb, var(--link) 10%, transparent) 0 50%, transparent 52%) no-repeat,
    rgba(255,255,255,.55);
  background-size: 160px 160px, 200px 200px, 140px 140px, auto;
}

section#region-main {
  background: transparent;
}

/* ==========================================================================
   4. Header & Logo
   ========================================================================== */

#header {
  max-width: 360px; /* Consistent definition */
  width: 70vw;
  height: auto;
  object-fit: contain;
}

/* ==========================================================================
   5. Buttons
   ========================================================================== */

.btn {
  border-radius: var(--radius-pill);
  font-weight: 700;
  padding: .65rem 1.1rem;
}

.btn-lg {
  padding: .85rem 1.4rem;
}

.btn-primary {
  background: linear-gradient(180deg, #1A56B3, var(--flow-blue)); /* Hardcoded gradient base with var */
  border-color: transparent;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  filter: brightness(.95);
  transform: translateY(-1px);
}

.btn-light {
  background: rgba(255,255,255,.9);
  border: 2px solid var(--flow-blue-200);
  color: var(--color-sky); /* Keeping the original explicit color */
}

.btn-warning {
  background: linear-gradient(180deg, #FFE66B, var(--flow-yellow)); /* Hardcoded gradient base with var */
  border: none;
  color: var(--text-primary); /* Use defined text primary */
}

/* ==========================================================================
   6. Card Navigation (ISC-Card)
   ========================================================================== */

.isc-card {
  border-radius: var(--radius-2xl); /* Consistent usage */
  box-shadow: var(--shadow-sm);
  min-height: 320px; /* Adjusted to the newer definition */
  background: rgba(255,255,255,.4);
  backdrop-filter: blur(6px);
  display: flex;
  overflow: hidden;
  position: relative;
  transition: transform .2s ease, box-shadow .2s ease;
}

.isc-card .card-img {
  height: 100%;
  object-fit: cover;
  filter: brightness(.85);
}

.isc-card-overlay {
  background: linear-gradient(180deg, rgba(0,0,0,0) 30%, rgba(0,0,0,.7) 100%);
}

.isc-card-content {
  padding: 1.5rem 1.25rem;
}

/* Hover/active emphasis */
.isc-card-link:hover .isc-card,
.isc-card-link:focus .isc-card {
  transform: translateY(-2px);
  box-shadow: 0 1rem 2rem rgba(0,0,0,.2);
  text-decoration: none;
}

.isc-card-link.active .isc-card {
  box-shadow: 0 0 0 .25rem color-mix(in srgb, var(--link) 25%, transparent); /* Using var for active state */
}

/* Color variants (solid/gradient) */
.isc-card--home {
  background: linear-gradient(135deg, var(--color-sky) 0%, var(--color-sand) 100%); /* Keeping as is, specific hex for gradient */
  color: #fff;
}
.isc-card--table {
  background: linear-gradient(135deg, var(--color-candy) 0%, var(--color-cloud) 100%); /* Keeping as is, specific hex for gradient */
  color: #fff;
}
.isc-card--rules {
  background: linear-gradient(135deg, var(--color-sunshine) 0%, var(--color-candy-light) 100%); /* Keeping as is, specific hex for gradient */
  color: #111; /* darker text for contrast */
}
.isc-card--about {
  background: linear-gradient(135deg, var(--color-sky-light) 0%, var(--color-mist) 100%); /* Keeping as is, specific hex for gradient */
  color: #fff;
}
.isc-card--hof {
  background: linear-gradient(135deg, var(--color-mist) 0%, var(--color-sand) 100%); /* Keeping as is, specific hex for gradient */
  color: #fff;
}

/* Typography tweaks inside cards */
.isc-card h3 {
  line-height: 1.1;
}
.isc-card .small {
  opacity: .95;
}
.isc-card-overlay h3, .isc-card-overlay .small {
  color: #fff;
}

/* ==========================================================================
   7. Carousel & Media
   ========================================================================== */

#carouselwell {
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,.35);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
}

#isc_owl .item video, #isc_owl .item img {
  max-width: 100%;
  height: auto;
  border-radius: 1rem;
}

/* ==========================================================================
   8. Rules / About Section
   ========================================================================== */

.rules-block, #about .p-5 {
  border-radius: var(--radius-xl);
  background: rgba(255,255,255,.35);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-sm);
}

#about .bg-dark {
  background: linear-gradient(180deg, color-mix(in srgb, var(--flow-cyan) 95%, transparent), color-mix(in srgb, var(--flow-blue-200) 85%, transparent)); /* Using var for gradient */
  color: #fff; /* Explicit white for contrast */
}
#about .bg-dark p {
  color: #ffff;
}

/* === Rules wrapper and block === */
.rules-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
}

.rules-block {
  position: relative;
  z-index: 2;
  background: linear-gradient(180deg,#fff 0%,#fdfdfd 100%); /* Keeping original gradient */
  border-radius: var(--radius-3xl); /* Using var */
  padding: 2rem;
  box-shadow: 0 10px 24px rgba(0,0,0,.08);
  text-align: left;
  border: 3px solid color-mix(in srgb, var(--link) 8%, transparent); /* Using var for border */
  max-width: 980px;
  width: 100%;
}

.rules-block h3 {
  font-family: "Fredoka", "Nunito", sans-serif;
  font-weight: 700;
  font-size: 2rem;
  color: var(--text-heading);
  text-align: center;
  margin-bottom: 1.5rem;
}

/* Section headings + lists (friendly) */
.rules-section h5 {
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--link); /* Using var */
  margin-bottom: .75rem;
  border-left: 6px solid #FAE013; /* Keeping original hex, close to yellow */
  padding-left: .5rem;
}

.rules-section ul {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1rem;
}

.rules-section ul li {
  position: relative;
  background: #F5F9FF; /* Keeping original hex, very light blue */
  border-radius: 1rem;
  padding: .6rem .9rem .6rem 2.2rem;
  margin-bottom: .5rem;
  font-size: 1rem;
  line-height: 1.45;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--link) 8%, transparent); /* Using var */
}

.rules-section ul li::before {
  content: "⭐";
  position: absolute;
  left: .8rem; top: .55rem;
  font-size: 1.1rem;
}

/* Give the final "How Points are Awarded" section a divider + plus markers */
.rules-section:last-child {
  border-top: 2px dashed color-mix(in srgb, var(--link) 20%, transparent); /* Using var */
  padding-top: 1rem;
  margin-top: 1.5rem;
}
.rules-section:last-child ul li::before {
  content: "➕";
  color: #2FC5F4; /* Keeping original hex, bright blue */
}

/* === Stickers (div-based, always visible) === */
.rules-sticker {
  position: absolute;
  z-index: 5;
  pointer-events: none;
}

.rules-sticker img {
  width: clamp(120px, 18vw, 320px);
  height: auto;
  display: block;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.15));
}

.rules-sticker.left {
  top: -80px; left: -14%;
  transform: rotate(15deg);
}

.rules-sticker.right {
  bottom: -80px; right: -14%;
  transform: rotate(-12deg);
}

/* Optional: gentle bob animation (disabled for reduced motion) */
@keyframes bob {
  0%,100% { transform: translateY(0) rotate(var(--rot,0deg)); }
  50%     { transform: translateY(-6px) rotate(var(--rot,0deg)); }
}

.rules-sticker.left  { --rot: 15deg; animation: bob 4.5s ease-in-out infinite; }
.rules-sticker.right { --rot:-12deg; animation: bob 5s   ease-in-out infinite; }

/* ==========================================================================
   9. DataTables
   ========================================================================== */

#interschooltable .dataTables_wrapper, #hofTable_wrapper {
  border-radius: var(--radius-3xl); /* Using var */
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(6px); /* Original backdrop-filter */
  box-shadow: var(--shadow-sm); /* Original shadow */
  padding: 1rem;
}

.table.dataTable thead th {
  background: linear-gradient(180deg, var(--flow-yellow-200), color-mix(in srgb, var(--flow-yellow) 65%, transparent)); /* Using vars for gradient */
  color: var(--text-primary); /* Using var */
  font-weight: 800;
  font-size: 1rem;
  text-transform: none;
  border-bottom: 3px solid rgba(0,0,0,.06);
}

.table.dataTable tbody td {
  font-size: 1rem;
}

.table.dataTable tbody tr:nth-child(odd) {
  background: rgba(255,255,255,.7);
}

.table.dataTable tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--flow-blue-200) 35%, transparent); /* Using var */
}

.table.dataTable tbody tr:hover {
  background: color-mix(in srgb, #2FC5F4 18%, transparent); /* Keeping original hex, bright blue */
}

/* Points + participants as friendly pills (non-breaking) */
#interschool_tablet tbody td:nth-child(2),
#interschool_tablet tbody td:nth-child(3),
#hofTable tbody td:nth-child(4) {
  font-weight: 800;
}

#interschool_tablet tbody td:nth-child(2)::before,
#hofTable tbody td:nth-child(4)::before {
  content: "⭐ ";
  font-weight: 700;
}

#interschool_tablet tbody td:nth-child(3)::before {
  content: "👫 ";
}

/* “View Students” toggle: make it look like a chip */
.student-toggle.btn.btn-link {
  border-radius: var(--radius-pill);
  background: var(--flow-cyan-200);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.05);
  text-decoration: none !important;
  padding: .35rem .75rem;
  font-weight: 700;
  color: #0b3a5c !important; /* Keeping original hex, dark blue */
}

.student-toggle[aria-expanded="true"] span {
  transform: rotate(90deg);
  display: inline-block;
}

/* Hall of Fame: trophy vibes */
#hof .card-title {
  font-family: "Fredoka";
  font-weight: 700;
}

#hofTable thead th:first-child::before {
  content: "🏆 ";
}

/* ==========================================================================
   10. Footer
   ========================================================================== */

#page-footer {
  background: color-mix(in srgb, var(--link) 90%, transparent); /* Using var */
  color: #fff; /* Explicit white for contrast */
  border-top-left-radius: var(--radius-3xl); /* Using var */
  border-top-right-radius: var(--radius-3xl); /* Using var */
  box-shadow: var(--shadow-lg);
  font-size: 16px;
}

#page-footer a {
  color: #9DE3FF; /* Keeping original hex, very light blue */
}

#page-footer a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   11. Go-to-top Button
   ========================================================================== */

#goto-top-link .btn {
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(4px);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
}

/* ==========================================================================
   12. Responsive Tweaks & Media Queries
   ========================================================================== */

@media (max-width: 768px) {
  .isc-card {
    min-height: 220px;
  }
  #carouselwell {
    padding: .75rem;
  }
  #header {
    max-width: 280px; /* Adjusted to newer definition */
  }
}

@media (max-width: 992px) {
  .rules-sticker.left {
    left: -10%;
  }
  .rules-sticker.right {
    right: -10%;
  }
}

@media (max-width: 768px) {
  .rules-block {
    padding: 1.25rem;
  }
  .rules-sticker img {
    width: clamp(80px, 28vw, 160px);
    opacity: .9;
  }
  .rules-sticker.left {
    top: -50px; left: -8%;
  }
  .rules-sticker.right {
    bottom: -50px; right: -8%;
  }
  .rules-section ul li {
    font-size: .95rem;
    padding-left: 2rem;
  }
}

/* ==========================================================================
   13. Accessibility & Motion Preferences
   ========================================================================== */

:focus-visible {
  outline: 4px solid var(--flow-cyan);
  outline-offset: 3px;
  border-radius: 12px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
  .rules-sticker.left,
  .rules-sticker.right {
    animation: none;
  }
}

/* ==========================================================================
   14. Contrast & Utility
   ========================================================================== */

/* Ensure contrast on dark sections/cards */
.bg-dark, #about .bg-dark {
  color: #fff;
}
.bg-dark a {
  color: #9DE3FF;
}