/* ==========================================================
   Sheena's Adventures — Global Stylesheet (Professional Polish)
   ========================================================== */

/* Base Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: #0B0F12;
  color: #D9E1E8;
  font-family: system-ui, -apple-system, Inter, Roboto, Arial, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Root Variables */
:root {
  --color-accent: #00BFA5;
  --color-accent-hover: #00D4B8;
  --color-bg: #0B0F12;
  --color-surface: #1A1F24;
  --color-text: #E8F0F7;
  --color-muted: #8A99A8;
  --ring: #00BFA5;
  --radius: 12px;
}

/* ==========================================================
   Header / Navigation (Sticky + Responsive)
   ========================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11,15,18,0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1rem 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.1rem;
  transition: color 0.2s ease;
}

.brand:hover {
  color: var(--color-accent);
}

.brand img {
  height: 48px;
  width: 48px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
}

.hamburger {
  display: block;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.2s ease;
  line-height: 1;
}

.hamburger:hover,
.hamburger:focus-visible {
  color: var(--color-accent);
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Mobile Nav - Hidden by default */
.site-nav {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
  width: 100%;
}

/* Open state for mobile menu */
body.open .site-nav {
  display: flex;
}

.site-nav a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  background: rgba(255,255,255,0.03);
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: var(--color-accent);
  background: rgba(0,191,165,0.12);
  outline: none;
  transform: translateX(4px);
}

/* Desktop Nav */
@media (min-width: 720px) {
  .hamburger { 
    display: none; 
  }
  
  .site-nav {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    margin-top: 0;
    width: auto;
  }
  
  .site-nav a {
    padding: 0.5rem 1rem;
    background: transparent;
  }
  
  .site-nav a:hover {
    transform: none;
  }
}

/* ==========================================================
   Hero Banner
   ========================================================== */

.hero-banner {
  position: relative;
  text-align: center;
  padding: 5rem 1.5rem 4rem;
  background: var(--color-bg);
  overflow: hidden;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-banner img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  opacity: 0.35;
}

.hero-banner .content {
  position: relative;
  z-index: 1;
  max-width: 700px;
}

.hero-banner h1 {
  font-size: clamp(2.2rem, 7vw, 3.5rem);
  margin: 0 0 1rem 0;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #fff;
}

.hero-banner p {
  color: #C5D3E0;
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  margin: 0 0 2rem 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.6;
}

.hero-buttons,
.cta-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}

/* Primary Button */
.btn {
  background: var(--color-accent);
  color: #0B0F12;
  border: none;
  border-radius: var(--radius);
  padding: 1rem 2rem;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0,191,165,0.25);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-2px);
  background: var(--color-accent-hover);
  box-shadow: 0 6px 20px rgba(0,191,165,0.35);
}

.btn:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}

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

/* Secondary Button */
.btn.secondary {
  background: transparent;
  color: var(--color-accent);
  border: 2px solid var(--color-accent);
  box-shadow: 0 0 0 rgba(0,191,165,0);
}

.btn.secondary:hover {
  background: rgba(0,191,165,0.15);
  border-color: var(--color-accent-hover);
  color: var(--color-accent-hover);
  box-shadow: 0 4px 16px rgba(0,191,165,0.2);
}

/* ==========================================================
   Sections
   ========================================================== */

section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.latest {
  text-align: center;
}

.latest h2 {
  margin: 0 0 2rem 0;
  font-size: clamp(2rem, 5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ==========================================================
   Cards / Grids
   ========================================================== */

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  padding: 1.5rem 0;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 0;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255,255,255,0.05);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 32px rgba(0,191,165,0.25);
  border-color: rgba(0,191,165,0.3);
}

.card img {
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  height: auto;
  display: block;
  margin: 0;
}

.card h3 {
  margin: 1.5rem 1.5rem 0.75rem;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text);
}

.card p {
  margin: 0 1.5rem 1rem;
  color: var(--color-muted);
  font-size: 1rem;
  line-height: 1.6;
}

.story-card {
  text-decoration: none;
  color: inherit;
  display: block;
}

/* Card Action Link/Button */
.text-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-accent);
  font-weight: 700;
  font-size: 1rem;
  margin: 0 1.5rem 1.5rem;
  padding: 0.75rem 1.5rem;
  background: rgba(0,191,165,0.1);
  border-radius: 8px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.text-link:hover {
  background: rgba(0,191,165,0.2);
  color: var(--color-accent-hover);
  transform: translateX(4px);
}

/* ==========================================================
   Footer
   ========================================================== */

.site-footer {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  color: var(--color-muted);
  background: var(--color-bg);
  font-size: 0.95rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: 4rem;
}

.site-footer p {
  margin: 0;
  line-height: 1.8;
}

.site-footer a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s ease;
  font-weight: 500;
}

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

/* ==========================================================
   Animations
   ========================================================== */

@keyframes slowPan {
  0% { transform: scale(1) translateX(0); }
  50% { transform: scale(1.05) translateX(-1%); }
  100% { transform: scale(1) translateX(0); }
}

@keyframes shimmer {
  0% { background-position: 0 0; }
  100% { background-position: 100px 100px; }
}

#bannerHero {
  will-change: transform;
}

/* ==========================================================
   Focus / Accessibility
   ========================================================== */

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

:focus:not(:focus-visible) {
  outline: none;
}

/* ==========================================================
   Utility Classes
   ========================================================== */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.pad {
  padding: 1.5rem;
}

.meta {
  color: var(--color-muted);
  font-size: 0.95rem;
}

/* ==========================================================
   JavaScript-Injected Styles
   ========================================================== */

#bannerHero {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 900ms ease;
  opacity: 1;
}

.fade-out {
  opacity: 0;
}

.cta-sparkle {
  position: absolute;
  pointer-events: none;
  top: 0;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  filter: blur(0.2px);
  opacity: 0;
  transition: opacity 300ms ease, transform 900ms ease;
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 600ms ease, transform 600ms ease;
}

.revealed {
  opacity: 1;
  transform: none;
}

#sandParticles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ==========================================================
   Loading States
   ========================================================== */

.card p:only-child {
  padding: 2rem 1.5rem;
}

/* Retry button in blog section */
#retryBlog {
  margin-top: 1rem;
  min-width: 140px;
}

/* ==========================================================
   Responsive Tweaks
   ========================================================== */

@media (min-width: 960px) {
  .hero-banner {
    padding: 7rem 2rem 6rem;
    min-height: 600px;
  }
  
  .hero-buttons .btn,
  .cta-buttons .btn {
    font-size: 1.05rem;
    padding: 1.1rem 2.5rem;
    min-width: 220px;
  }
  
  section {
    padding: 4rem 2rem;
  }
}

/* ==========================================================
   Blog Page Styles
   ========================================================== */

.page-blog {
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.blog-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  width: 100%;
}

.blog-header {
  text-align: center;
  margin-bottom: 3rem;
}

.page-title {
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  font-weight: 800;
  margin: 0 0 1rem 0;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.blog-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  color: var(--color-muted);
  margin: 0;
  max-width: 600px;
  margin: 0 auto;
}

/* Blog Grid */
.blog-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
}

@media (min-width: 640px) {
  .blog-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 960px) {
  .blog-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }
}

/* Blog Card */
.blog-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  padding: 2rem 1.5rem;
}

.blog-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,191,165,0.2);
  border-color: rgba(0,191,165,0.3);
}

.blog-card-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.blog-card-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
  line-height: 1.3;
}

.blog-read-btn {
  background: var(--color-accent) !important;
  color: #0B0F12 !important;
  text-decoration: none !important;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  align-self: flex-start;
  box-shadow: 0 2px 8px rgba(0,191,165,0.2);
}

.blog-read-btn:hover {
  background: var(--color-accent-hover) !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,191,165,0.35);
  color: #0B0F12 !important;
}

.blog-card-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2rem 1.5rem;
  text-decoration: none;
  color: inherit;
  gap: 1rem;
}

.blog-card-meta {
  font-size: 0.9rem;
  color: var(--color-accent);
  margin: 0;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.blog-card-arrow {
  font-size: 2rem;
  color: var(--color-accent);
  transition: transform 0.3s ease;
  line-height: 1;
  flex-shrink: 0;
}

.blog-card:hover .blog-card-arrow {
  transform: translateX(8px);
}

/* Ensure footer stays at bottom */
.page-blog .site-footer {
  margin-top: auto;
}

/* ==========================================================
   Blog Post Page Styles
   ========================================================== */

.page-blog-post {
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Post Hero Banner */
.post-hero {
  position: relative;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--color-surface);
}

.post-hero-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.3;
  z-index: 0;
}

.post-hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
  padding: 3rem 1.5rem;
  text-align: center;
}

.post-breadcrumb {
  margin-bottom: 1.5rem;
}

.post-breadcrumb a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.post-breadcrumb a:hover {
  color: var(--color-accent-hover);
}

.post-hero-title {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 1rem 0;
  color: #fff;
  letter-spacing: -0.02em;
}

.post-meta {
  color: var(--color-muted);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Post Main Content */
.post-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
  width: 100%;
  flex: 1;
}

.post-article {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  border: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 3rem;
}

/* Prose Styling */
.post-prose {
  color: var(--color-text);
  line-height: 1.8;
}

.post-prose p {
  margin: 0 0 1.5rem 0;
  font-size: 1.1rem;
}

.post-prose p:last-child {
  margin-bottom: 0;
}

.post-prose strong {
  color: #fff;
  font-weight: 700;
}

.post-prose em {
  color: var(--color-accent);
  font-style: italic;
}

.post-prose code {
  background: rgba(0,191,165,0.1);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

.error-message {
  text-align: center;
  padding: 2rem;
  color: var(--color-muted);
}

/* Post CTA Section */
.post-cta {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.05);
}

.post-cta h3 {
  font-size: 1.75rem;
  margin: 0 0 1rem 0;
  font-weight: 700;
  color: var(--color-text);
}

.post-cta p {
  color: var(--color-muted);
  font-size: 1.1rem;
  margin: 0 0 2rem 0;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Responsive */
@media (max-width: 720px) {
  .post-hero {
    min-height: 350px;
  }

  .post-article {
    padding: 2rem 1.5rem;
  }

  .post-prose p {
    font-size: 1.05rem;
  }

  .post-cta {
    padding: 2rem 1.5rem;
  }
}

/* ==========================================================
   Game Page Styles (Gem Stack)
   ========================================================== */

.page-game {
  background: var(--color-bg);
  min-height: 100vh;
}

.game-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.game-header {
  text-align: center;
  margin-bottom: 2rem;
}

.game-header h1 {
  font-size: clamp(2rem, 5vw, 2.5rem);
  margin: 0 0 1.5rem 0;
  font-weight: 800;
  color: var(--color-text);
}

/* Game buttons - prevent conflicts with global .btn */
.game-btn {
  min-width: 140px !important;
}

.controls.primary {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* HUD Pills */
.hud {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.pill {
  background: var(--color-surface);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--color-text);
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 120px;
  text-align: center;
}

.pill span {
  color: var(--color-accent);
}

/* Canvas Container */
.game-stage {
  margin-bottom: 1.5rem;
}

.canvas-shell {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  background: linear-gradient(180deg, #121821 0%, #0B0F12 100%);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  border: 2px solid rgba(0,191,165,0.2);
}

#gameCanvas {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 640 / 960;
}

/* On-screen Controls */
.controls.on-screen {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-width: 400px;
  margin: 0 auto 2rem;
}

.ctrl {
  min-height: 56px;
  min-width: 56px;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.ctrl:hover {
  background: rgba(0,191,165,0.1);
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.ctrl:active {
  transform: translateY(0);
  background: rgba(0,191,165,0.2);
}

/* Position drop button in center of second row */
.ctrl[data-control="down"] {
  grid-column: 1;
}

.ctrl[data-control="drop"] {
  grid-column: 3;
}

/* How to Play */
.howto {
  max-width: 600px;
  margin: 2rem auto;
}

.howto details {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid rgba(255,255,255,0.05);
}

.howto summary {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.howto summary::-webkit-details-marker {
  display: none;
}

.howto summary::before {
  content: '▶ ';
  color: var(--color-accent);
  display: inline-block;
  transition: transform 0.2s ease;
}

.howto details[open] summary::before {
  transform: rotate(90deg);
}

.howto-body {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: var(--color-muted);
  line-height: 1.7;
}

.howto-body p {
  margin: 0 0 1rem 0;
}

.howto-body ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

.howto-body li {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
}

.howto-body li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--color-accent);
}

.howto-body kbd {
  background: rgba(0,191,165,0.1);
  border: 1px solid var(--color-accent);
  padding: 0.2em 0.5em;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
  color: var(--color-accent);
}

/* Desktop: Hide touch controls */
@media (min-width: 720px) {
  .controls.on-screen {
    display: none;
  }
   }
