/* ==========================================
   HOGWARTS ARCADE SCAVENGER HUNT
   Stylesheet - Phase 1: Foundation
   ========================================== */

/* ==========================================
   IMPORTS & FONTS
   ========================================== */

@font-face {
  font-family: 'Harry Potter';
  src: url('fonts/harryp.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Lato:wght@400;700&display=swap');

/* ==========================================
   CSS VARIABLES
   ========================================== */

:root {
  /* Colors */
  --ink: #ffffff;  /* Pure white for maximum readability */
  --gold: #d6bb22;
  --burgundy: #e63946;
  --emerald: #009d64;
  --bronze: #CD853F;
  --parchment: #2c1810;  /* Dark castle stone */
  --parchment-light: #1a1a2e;  /* Dark blue */
  --parchment-dark: #0f0f23;  /* Very dark */
  --shadow: rgba(0, 0, 0, 0.7);
  --shadow-light: rgba(0, 0, 0, 0.4);
  
  /* Spacing */
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* Typography */
  --font-display: 'Harry Potter', 'Cinzel', serif;
  --font-body: 'Lato', sans-serif;
}

/* ==========================================
   RESET & BASE STYLES
   ========================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Performance optimizations */
.sparkle-particle,
.view,
.level-section {
  will-change: transform, opacity;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 1.25rem;
  line-height: 1.7;
  color: var(--ink);
  font-weight: 400;
  min-height: 100vh;
  overflow-x: hidden;
  animation: fadeIn 0.6s ease-in-out;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  
  /* Harry Potter Dark Castle Background */
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 215, 0, 0.08), transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(138, 43, 226, 0.10), transparent 45%),
    radial-gradient(circle at 50% 80%, rgba(30, 144, 255, 0.08), transparent 50%),
    linear-gradient(180deg, #0b0b0f 0%, #1a1a2e 40%, #2b1d0e 100%);
  background-attachment: fixed;
}

/* ==========================================
   TYPOGRAPHY
   ========================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--spacing-md);
}

h1 { font-size: 4rem; }
h2 { font-size: 3rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
  margin-bottom: var(--spacing-md);
}

strong {
  font-weight: 600;
  color: var(--burgundy);
}

/* ==========================================
   LAYOUT
   ========================================== */

.container {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  padding: var(--spacing-lg);
  position: relative;
}

/* View Management */
.view {
  display: none !important;
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
}

.view.active {
  display: block !important;
  animation: fadeIn 0.5s ease-in-out forwards;
}

.view.exiting {
  animation: fadeOut 0.3s ease-in-out forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Loading state animation */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loading {
  animation: spin 1s linear infinite;
}

/* ==========================================
   BUTTONS
   ========================================== */

button {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  padding: var(--spacing-md) var(--spacing-lg);
  border: 2px solid var(--ink);
  background: var(--parchment);
  color: var(--ink);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 48px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

button:hover {
  background: var(--ink);
  color: var(--parchment);
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-2px);
}

button:active {
  transform: translateY(0) scale(0.98);
  transition: transform 0.1s ease;
}

@media (hover: none) and (pointer: coarse) {
  /* Touch device specific styles */
  button:active {
    transform: scale(0.95);
    opacity: 0.9;
  }
  
  .class-item:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--shadow-light);
  color: var(--ink);
  position: relative;
}

button.loading::after {
  content: '⏳';
  margin-left: 8px;
  animation: spin 1s linear infinite;
}

button:disabled:hover {
  transform: none;
  box-shadow: none;
  background: var(--shadow-light);
  color: var(--ink);
}

button.hidden {
  display: none;
}

/* Back Button */
.back-btn {
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 0.9rem;
  background: transparent;
  border: 1px solid var(--ink);
}

.back-btn:hover {
  background: var(--shadow-light);
}

/* ==========================================
   INPUTS
   ========================================== */

input[type="text"],
input[type="password"] {
  font-family: var(--font-body);
  font-size: 1.125rem;
  padding: var(--spacing-md);
  width: 100%;
  border: 2px solid var(--gold);
  border-radius: var(--radius-md);
  background: rgba(20, 20, 40, 0.95);
  color: var(--ink);
  transition: all 0.3s ease;
  min-height: 56px;
  margin-bottom: var(--spacing-md);
}

input::placeholder {
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
}

input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 15px var(--gold), 0 0 25px rgba(212, 175, 55, 0.4);
  animation: pulse-glow 2s ease-in-out infinite;
}

input:disabled {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--emerald);
  cursor: not-allowed;
  opacity: 0.7;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 15px var(--gold);
  }
  50% {
    box-shadow: 0 0 25px var(--gold), 0 0 40px rgba(212, 175, 55, 0.6);
  }
}

/* Shake animation for errors */
.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Success flash animation */
.success-flash {
  animation: success-flash 0.6s ease-in-out;
}

@keyframes success-flash {
  0%, 100% { 
    background: rgba(15, 15, 35, 0.92);
    border-color: var(--gold);
  }
  50% { 
    background: rgba(45, 80, 22, 0.3);
    border-color: var(--emerald);
    box-shadow: 0 0 20px rgba(45, 80, 22, 0.6);
  }
}

/* Success button state */
button.success {
  background: var(--emerald);
  color: white;
  border-color: var(--emerald);
}

button.success:hover {
  background: var(--emerald);
  color: white;
}

/* Pulse animation for active level */
@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 12px var(--shadow);
  }
  50% {
    box-shadow: 0 6px 20px var(--shadow), 0 0 30px rgba(212, 175, 55, 0.3);
    transform: translateX(4px);
  }
}

/* Success message styling */
.success-message {
  color: var(--emerald);
  font-weight: 600;
  text-align: center;
  padding: var(--spacing-md);
  background: rgba(45, 80, 22, 0.1);
  border: 1px solid var(--emerald);
  border-radius: var(--radius-md);
  margin: var(--spacing-md) 0;
}

/* ==========================================
   HOME VIEW - CLASS SCHEDULE
   ========================================== */

.marauders-title {
  text-align: center;
  color: var(--burgundy);
  margin-bottom: var(--spacing-sm);
  font-size: 4rem;
}

.subtitle {
  text-align: center;
  font-style: italic;
  color: var(--bronze);
  margin-bottom: var(--spacing-xl);
  font-size: 1.5rem;
}

.class-list {
  list-style: none;
  margin-bottom: var(--spacing-xl);
}

.class-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  border: 2px solid var(--gold);
  border-radius: var(--radius-lg);
  background: rgba(15, 15, 35, 0.92);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.class-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.2), transparent);
  transition: left 0.5s ease;
}

.class-item:hover::before {
  left: 100%;
}

.class-item:hover {
  transform: translateX(8px);
  box-shadow: 0 4px 12px var(--shadow);
  background: rgba(25, 25, 70, 0.95);
  border-color: var(--gold);
}

.class-item.locked {
  opacity: 0.5;
  filter: grayscale(100%);
  cursor: not-allowed;
  pointer-events: none;
}

.class-item.locked::before {
  display: none;
}

.class-item.locked:hover {
  transform: none;
  box-shadow: none;
}

.class-item.completed {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--gold);
  cursor: default;
  pointer-events: none;
}

.class-item.completed::before {
  display: none;
}

.class-icon {
  font-size: 2rem;
  min-width: 2rem;
}

.class-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.class-name {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--ink);
}

.class-teacher {
  font-size: 1.5rem;
  color: var(--bronze);
  font-style: italic;
}

.status-badge {
  font-family: var(--font-display);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  background: var(--shadow-light);
  color: var(--ink);
  white-space: nowrap;
}

.status-badge.available {
  background: var(--emerald);
  color: #ffffff;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.status-badge.completed {
  background: var(--gold);
  color: var(--ink);
}

/* PIN Progress Display */
.pin-progress {
  text-align: center;
  padding: var(--spacing-lg);
  border: 2px solid var(--gold);
  border-radius: var(--radius-lg);
  background: rgba(212, 175, 55, 0.05);
}

.pin-progress p {
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
}

.pin-display {
  display: flex;
  justify-content: center;
  gap: var(--spacing-md);
}

.pin-digit {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  width: 50px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--gold);
  border-radius: var(--radius-md);
  background: rgba(15, 15, 35, 0.92);
  color: var(--ink);
  font-weight: 700;
}

.pin-digit.revealed {
  color: var(--gold);
  background: rgba(212, 175, 55, 0.3);
  border-color: var(--gold);
  animation: revealDigit 0.5s ease-in-out;
  font-weight: 700;
}

@keyframes revealDigit {
  0% {
    transform: rotateY(90deg);
    opacity: 0;
  }
  100% {
    transform: rotateY(0);
    opacity: 1;
  }
}

/* ==========================================
   LEVEL VIEW - CLASS DETAIL
   ========================================== */

.class-title {
  text-align: center;
  color: var(--gold);
  margin-bottom: var(--spacing-xl);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.level-section {
  margin-bottom: var(--spacing-xl);
  padding: var(--spacing-lg);
  border: 2px solid var(--gold);
  border-radius: var(--radius-lg);
  background: rgba(15, 15, 35, 0.92);
  transition: all 0.5s ease, opacity 0.3s ease, transform 0.3s ease;
}

.level-section[data-state="locked"] {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(100%);
  transform: scale(0.98);
  max-height: 100px;
  overflow: hidden;
}

.level-section[data-state="active"] {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
  animation: ink-appear 1s ease-in-out;
  transform: scale(1);
  max-height: none;
}

.level-section[data-state="completed"] {
  background: rgba(212, 175, 55, 0.05);
  border-color: var(--emerald);
  opacity: 0.7;
  transform: scale(0.98);
}

@keyframes ink-appear {
  from {
    opacity: 0;
    filter: blur(2px);
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--shadow-light);
}

.section-header h3 {
  margin: 0;
  color: var(--burgundy);
}

.section-icon {
  font-size: 1.5rem;
}

/* Part A: Riddle */
.riddle-scroll {
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  border: 1px solid var(--bronze);
  border-radius: var(--radius-md);
  background: rgba(139, 69, 19, 0.05);
}

.riddle-text {
  font-size: 1.25rem;
  line-height: 1.8;
  text-align: center;
  font-style: italic;
  color: var(--ink);
  margin: 0;
}

/* Part B: Task */
.task-card {
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  border: 1px solid var(--emerald);
  border-radius: var(--radius-md);
  background: rgba(45, 80, 22, 0.05);
}

.task-card h4 {
  color: var(--emerald);
  margin-bottom: var(--spacing-sm);
}

.task-description {
  font-size: 1.125rem;
  line-height: 1.8;
  margin-bottom: var(--spacing-lg);
}

.teacher-verify {
  padding: var(--spacing-md);
  border-left: 3px solid var(--gold);
  background: rgba(212, 175, 55, 0.1);
}

.teacher-verify p {
  margin: 0;
}

.teacher-verify p:first-child {
  margin-bottom: var(--spacing-xs);
}

.hint {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--bronze);
}

/* Part C: Reward */
.completion-card {
  text-align: center;
  padding: var(--spacing-xl);
}

.completion-card h4 {
  color: var(--gold);
  font-size: 1.75rem;
  margin-bottom: var(--spacing-md);
}

.pin-reveal {
  margin: var(--spacing-xl) 0;
}

.pin-reveal p {
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: var(--spacing-md);
}

.digit-display {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--burgundy);
  padding: var(--spacing-lg);
  border: 3px solid var(--gold);
  border-radius: var(--radius-lg);
  background: rgba(212, 175, 55, 0.2);
  min-width: 80px;
  animation: revealDigit 0.8s ease-in-out;
}

.progress-hint {
  font-size: 0.95rem;
  font-style: italic;
  color: var(--bronze);
  margin-top: var(--spacing-lg);
}

/* Input Groups */
.input-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

/* Error Messages */
.error-msg {
  color: var(--burgundy);
  font-style: italic;
  text-align: center;
  padding: var(--spacing-sm);
  background: rgba(128, 0, 32, 0.1);
  border-radius: var(--radius-sm);
  margin-top: var(--spacing-sm);
}

.error-msg.hidden {
  display: none;
}

/* ==========================================
   VICTORY VIEW
   ========================================== */

.victory-title {
  text-align: center;
  color: var(--gold);
  font-size: 2.5rem;
  margin-bottom: var(--spacing-xl);
  animation: victoryBounce 1.2s ease-in-out;
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
}

@keyframes victoryBounce {
  0%, 100% { 
    transform: scale(1) translateY(0);
    opacity: 1;
  }
  10% { 
    transform: scale(0.9) translateY(-10px);
    opacity: 0;
  }
  30% { 
    transform: scale(1.1) translateY(0);
  }
  50% { 
    transform: scale(0.95);
  }
  70% { 
    transform: scale(1.02);
  }
}

.victory-card {
  text-align: center;
  padding: var(--spacing-xl);
  border: 3px solid var(--gold);
  border-radius: var(--radius-lg);
  background: rgba(212, 175, 55, 0.1);
  margin-bottom: var(--spacing-xl);
}

.victory-message {
  font-size: 1.25rem;
  margin-bottom: var(--spacing-xl);
}

.final-pin {
  margin: var(--spacing-xl) 0;
}

.final-pin h3 {
  color: var(--burgundy);
  margin-bottom: var(--spacing-lg);
}

.pin-display.large {
  gap: var(--spacing-lg);
}

.pin-display.large .pin-digit {
  font-size: 2.5rem;
  width: 70px;
  height: 80px;
}

.prize-instruction {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--emerald);
}

/* ==========================================
   ANIMATIONS - SPARKLES
   ========================================== */

.sparkle-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
  pointer-events: none;
  animation: sparkle 1s ease-out forwards;
  z-index: 1000;
}

@keyframes sparkle {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

/* Tablet (Landscape) */
@media (min-width: 768px) {
  .container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--spacing-xl);
  }
  
  .input-group {
    flex-direction: row;
  }
  
  .input-group input {
    margin-bottom: 0;
  }
  
  .input-group button {
    white-space: nowrap;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .container {
    max-width: 700px;
  }
  
  .class-item:hover {
    transform: translateX(12px);
  }
}

/* Small Mobile */
@media (max-width: 360px) {
  html {
    font-size: 14px;
  }
  
  .container {
    padding: var(--spacing-md);
  }
  
  .pin-digit {
    width: 40px;
    height: 50px;
    font-size: 1.5rem;
  }
  
  .digit-display {
    font-size: 2.5rem;
    min-width: 60px;
  }
  
  .class-item {
    padding: var(--spacing-md);
  }
  
  button {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.9rem;
  }
}

/* Prevent zoom on input focus (iOS Safari) */
@media screen and (max-width: 767px) {
  input[type="text"],
  input[type="password"] {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}
