/* ===========================================
   MARINE SCIENCE IGCSE REVISION - MAIN STYLES
   Post-It Note + Ocean Theme
   =========================================== */

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

/* ---- CSS Custom Properties ---- */
:root {
  /* Post-it note colors */
  --postit-yellow: #fff740;
  --postit-pink: #ff7eb3;
  --postit-blue: #7afcff;
  --postit-green: #98fb98;
  --postit-orange: #ffb347;
  --postit-lavender: #c3b1e1;

  /* Ocean palette */
  --ocean-deep: #0a2463;
  --ocean-mid: #1e6091;
  --ocean-light: #3da5d9;
  --seafoam: #73d2de;
  --ocean-surface: #b8e4f0;
  --sand: #f5f0e1;
  --sand-light: #faf7f0;
  --coral: #e8505b;
  --kelp: #2d936c;
  --corkboard: #c4956a;
  --corkboard-dark: #a67c52;

  /* Text */
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-light: #ffffff;

  /* Layout */
  --sidebar-width: 280px;
  --header-height: 70px;
  --content-max-width: 1000px;

  /* Fonts */
  --font-handwritten: 'Patrick Hand', cursive;
  --font-body: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Shadows */
  --shadow-postit: 2px 3px 8px rgba(0, 0, 0, 0.15);
  --shadow-postit-hover: 4px 6px 14px rgba(0, 0, 0, 0.22);
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--sand-light);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-handwritten);
  line-height: 1.3;
}

h1 { font-size: 2.4rem; }
h2 { font-size: 1.9rem; color: var(--ocean-deep); }
h3 { font-size: 1.5rem; color: var(--ocean-mid); }
h4 { font-size: 1.25rem; }

p { margin-bottom: 1rem; }

a {
  color: var(--ocean-mid);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover { color: var(--coral); }

strong { color: var(--ocean-deep); }

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

/* ---- Header with Wave ---- */
.site-header {
  background: linear-gradient(135deg, var(--ocean-deep) 0%, var(--ocean-mid) 50%, var(--seafoam) 100%);
  color: var(--text-light);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}

.site-header h1 {
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-header h1 a {
  color: var(--text-light);
  text-decoration: none;
}

.site-header .header-fish {
  font-size: 1.5rem;
}

/* Wave decoration under header */
.wave-divider {
  width: 100%;
  height: 40px;
  background: var(--sand-light);
  position: relative;
  overflow: hidden;
}

.wave-divider::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 0;
  width: 200%;
  height: 40px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 40'%3E%3Cpath d='M0 20 Q150 0 300 20 T600 20 T900 20 T1200 20 V0 H0 Z' fill='%231e6091'/%3E%3C/svg%3E") repeat-x;
  background-size: 600px 40px;
  animation: wave-slide 8s linear infinite;
}

@keyframes wave-slide {
  from { transform: translateX(0); }
  to { transform: translateX(-600px); }
}

/* ---- Top Navigation ---- */
.topic-nav {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.topic-nav a {
  color: var(--text-light);
  background: rgba(255, 255, 255, 0.15);
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.2s;
  white-space: nowrap;
}

.topic-nav a:hover,
.topic-nav a.active {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.05);
  color: var(--text-light);
}

/* Hamburger menu for mobile */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0.3rem;
}

/* ---- Page Layout ---- */
.page-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: calc(100vh - var(--header-height));
}

/* ---- Sidebar ---- */
.sidebar {
  background: linear-gradient(180deg, var(--ocean-surface) 0%, var(--sand) 100%);
  border-right: 3px solid var(--seafoam);
  padding: 1.5rem 1rem;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar h3 {
  font-family: var(--font-handwritten);
  font-size: 1.2rem;
  color: var(--ocean-deep);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px dashed var(--seafoam);
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li {
  margin-bottom: 0.3rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.sidebar-nav a:hover {
  background: rgba(115, 210, 222, 0.3);
  color: var(--ocean-deep);
  transform: translateX(4px);
}

.sidebar-nav a.active {
  background: var(--seafoam);
  color: var(--ocean-deep);
  font-weight: 700;
}

.sidebar-nav .check-icon {
  color: var(--kelp);
  font-weight: bold;
}

/* Sidebar progress bar */
.sidebar-progress {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px dashed var(--seafoam);
}

.sidebar-progress-label {
  font-family: var(--font-handwritten);
  font-size: 1rem;
  color: var(--ocean-deep);
  margin-bottom: 0.5rem;
}

/* ---- Main Content ---- */
.content {
  padding: 2rem;
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
}

/* ---- Section Styling ---- */
.subtopic-section {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 3px dashed var(--ocean-surface);
}

.subtopic-section:last-of-type {
  border-bottom: none;
}

.subtopic-section h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
}

.section-number {
  background: var(--ocean-deep);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Content cards look like post-its */
.content-card {
  background: var(--sand);
  padding: 1.5rem;
  border-radius: 2px;
  box-shadow: var(--shadow-postit);
  margin-bottom: 1.5rem;
  position: relative;
}

.content-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 25px 25px;
  border-color: transparent transparent var(--sand-light) transparent;
  filter: drop-shadow(-1px -1px 1px rgba(0,0,0,0.05));
}

/* Key term highlight */
.key-term {
  background: linear-gradient(180deg, transparent 60%, rgba(255, 247, 64, 0.4) 60%);
  font-weight: 700;
  color: var(--ocean-deep);
}

/* Key facts box styled as a post-it */
.key-facts {
  background: var(--postit-yellow);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-postit);
  transform: rotate(-0.5deg);
  font-family: var(--font-handwritten);
  font-size: 1.1rem;
  position: relative;
}

.key-facts::before {
  content: 'Key Facts';
  display: block;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  text-decoration: underline;
  text-decoration-color: var(--coral);
}

.key-facts ul {
  margin-left: 1.2rem;
}

.key-facts li {
  margin-bottom: 0.4rem;
}

/* Tip box */
.tip-box {
  background: var(--postit-green);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-postit);
  transform: rotate(0.5deg);
  font-family: var(--font-handwritten);
  font-size: 1.05rem;
}

.tip-box::before {
  content: 'Exam Tip!';
  display: block;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

/* Warning box */
.warning-box {
  background: var(--postit-pink);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-postit);
  transform: rotate(-0.3deg);
  font-family: var(--font-handwritten);
  font-size: 1.05rem;
}

.warning-box::before {
  content: 'Common Mistake!';
  display: block;
  font-weight: 700;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--coral);
}

/* ---- Corkboard (Landing Page) ---- */
.corkboard {
  background:
    url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E"),
    linear-gradient(135deg, var(--corkboard) 0%, var(--corkboard-dark) 100%);
  padding: 2.5rem;
  border-radius: 8px;
  border: 8px solid #8B6914;
  box-shadow: inset 0 0 30px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.2);
  min-height: 400px;
}

/* Topic cards on corkboard */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  padding: 1rem;
}

.topic-card {
  padding: 1.5rem;
  box-shadow: var(--shadow-postit);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  min-height: 200px;
  font-family: var(--font-handwritten);
}

.topic-card:hover {
  transform: scale(1.03) rotate(0deg) !important;
  box-shadow: var(--shadow-postit-hover);
  z-index: 10;
}

.topic-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 30px 30px;
  border-color: transparent transparent rgba(255,255,255,0.3) transparent;
}

/* Pin effect on post-its */
.topic-card::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  background: radial-gradient(circle, #ff4444 0%, #cc0000 60%, #990000 100%);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  z-index: 5;
}

/* Different card colors/rotations */
.topic-card:nth-child(1) { background: var(--postit-yellow); transform: rotate(-2deg); }
.topic-card:nth-child(2) { background: var(--postit-pink); transform: rotate(1.5deg); }
.topic-card:nth-child(3) { background: var(--postit-blue); transform: rotate(-1deg); }
.topic-card:nth-child(4) { background: var(--postit-green); transform: rotate(2deg); }
.topic-card:nth-child(5) { background: var(--postit-orange); transform: rotate(-1.5deg); }
.topic-card:nth-child(6) { background: var(--postit-lavender); transform: rotate(1deg); }

.topic-card h3 {
  font-size: 1.4rem;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  padding-top: 0.5rem;
}

.topic-card .topic-number {
  font-size: 2.5rem;
  font-weight: 800;
  opacity: 0.2;
  position: absolute;
  top: 10px;
  right: 15px;
  font-family: var(--font-body);
}

.topic-card ul {
  list-style: none;
  font-size: 0.95rem;
  color: var(--text-primary);
  opacity: 0.85;
}

.topic-card ul li {
  margin-bottom: 0.25rem;
  padding-left: 1rem;
  position: relative;
}

.topic-card ul li::before {
  content: '~';
  position: absolute;
  left: 0;
  color: var(--ocean-mid);
  font-weight: bold;
}

.topic-card .card-link {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.4rem 1rem;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 15px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.95rem;
  transition: background 0.2s;
}

.topic-card .card-link:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ---- Progress Bar ---- */
.progress-bar {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 0.75rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--kelp), var(--seafoam));
  border-radius: 5px;
  transition: width 0.5s ease;
}

.progress-text {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 25px;
  font-family: var(--font-handwritten);
  font-size: 1.05rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-soft);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-postit-hover);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--ocean-mid);
  color: white;
}

.btn-primary:hover { background: var(--ocean-deep); }

.btn-success {
  background: var(--kelp);
  color: white;
}

.btn-success:hover { background: #238c5a; }

.btn-warning {
  background: var(--coral);
  color: white;
}

.btn-warning:hover { background: #d13e47; }

.btn-secondary {
  background: var(--sand);
  color: var(--text-primary);
  border: 2px solid var(--ocean-light);
}

.btn-secondary:hover { background: var(--ocean-surface); }

.btn-small {
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
}

/* ---- Mark Complete Checkbox ---- */
.mark-complete {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--ocean-surface);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-handwritten);
  font-size: 1.05rem;
  transition: background 0.2s;
}

.mark-complete:hover {
  background: var(--seafoam);
}

.mark-complete input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--kelp);
}

/* ---- Section Quick Links ---- */
.section-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}

.section-links .btn {
  font-size: 0.95rem;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--ocean-deep);
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.9rem;
  margin-top: 3rem;
}

.site-footer a {
  color: var(--seafoam);
}

/* ---- Sea Creatures Decorations ---- */
.sea-creature {
  position: absolute;
  opacity: 0.12;
  pointer-events: none;
  font-size: 3rem;
}

.sea-creature.fish { color: var(--ocean-light); }
.sea-creature.starfish { color: var(--postit-orange); }
.sea-creature.turtle { color: var(--kelp); }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .topic-nav { display: none; }

  .hamburger { display: block; }

  .page-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    width: var(--sidebar-width);
    transform: translateX(-100%);
    z-index: 999;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    padding: 1.5rem;
  }
}

@media (max-width: 768px) {
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.5rem; }

  .site-header { padding: 0.75rem 1rem; }
  .site-header h1 { font-size: 1.3rem; }

  .corkboard {
    padding: 1.5rem;
    border-width: 5px;
  }

  .topic-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .content { padding: 1rem; }

  .topic-card {
    transform: rotate(0deg) !important;
  }
}

@media (max-width: 480px) {
  html { font-size: 14px; }

  .corkboard { padding: 1rem; }
}

/* ---- Landing Page Intro ---- */
.landing-intro {
  text-align: center;
  padding: 2rem 1rem;
  max-width: 700px;
  margin: 0 auto 2rem;
}

.landing-intro h2 {
  font-size: 2.2rem;
  color: var(--ocean-deep);
  margin-bottom: 0.5rem;
}

.landing-intro p {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

/* ---- Quick Links Bar ---- */
.quick-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 2rem 0;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--sand);
}

::-webkit-scrollbar-thumb {
  background: var(--seafoam);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ocean-light);
}

/* ---- Graph Paper / Field Notebook Texture ---- */
.content-card {
  background:
    linear-gradient(rgba(184, 228, 240, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(184, 228, 240, 0.08) 1px, transparent 1px),
    var(--sand);
  background-size: 20px 20px, 20px 20px;
  border-left: 3px solid #e8505b;
  position: relative;
}

.content-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 35px;
  width: 1px;
  height: 100%;
  background: rgba(232, 80, 91, 0.15);
}

/* Tape effect on post-it notes */
.key-facts::after,
.tip-box::after,
.warning-box::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 80px;
  height: 18px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 2px;
}

.key-facts, .tip-box, .warning-box {
  position: relative;
  margin-top: 2rem;
}

/* Watercolour sea creature accents */
.subtopic-section::after {
  content: '';
  display: block;
  height: 40px;
  margin-top: 1rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 800 40'%3E%3Cpath d='M0 20 Q100 5 200 20 T400 20 T600 20 T800 20' fill='none' stroke='%2373d2de' stroke-width='2' opacity='0.3'/%3E%3Cpath d='M0 25 Q100 10 200 25 T400 25 T600 25 T800 25' fill='none' stroke='%233da5d9' stroke-width='1.5' opacity='0.2'/%3E%3C/svg%3E") no-repeat center;
  background-size: 100% 40px;
  opacity: 0.6;
}

.subtopic-section:last-of-type::after {
  display: none;
}

/* Hand-drawn style borders for tables */
.data-table {
  border: 2px solid var(--ocean-mid);
  border-radius: 4px;
  overflow: hidden;
}

/* Field notebook page header style */
.content > h1 {
  position: relative;
  padding-bottom: 0.75rem;
}

.content > h1::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--coral), var(--ocean-mid), var(--seafoam));
  border-radius: 2px;
}

/* Specimen-card style for topic cards on corkboard */
.topic-card {
  background-size: 20px 20px;
}

.topic-card:nth-child(1) {
  background-image: linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px);
}

/* Scientific sketch style dividers between sections */
.section-links {
  background: rgba(184, 228, 240, 0.15);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  border: 1px dashed var(--seafoam);
}

/* Decorative marine SVG accents on landing page */
.landing-intro::before {
  content: '🪸 🐚 🔬 🐠 🧪';
  display: block;
  font-size: 1.5rem;
  letter-spacing: 0.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

/* Enhanced sidebar with notebook feel */
.sidebar {
  background:
    linear-gradient(rgba(184, 228, 240, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, var(--ocean-surface) 0%, var(--sand) 100%);
  background-size: 1px 24px, 100% 100%;
}

/* ---- Utilities ---- */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }
