/* ==========================================================================
   Exam Timer - A single-viewport timer app with notes
   Written by HeyAvijitRoy
   ========================================================================== */

/* Global custom properties
   ========================================================================== */
:root {
  --bg: #0b0f14;      /* Dark background for better readability */
  --fg: #e8f0ff;      /* Light text for contrast */
  --muted: #9bb0c9;   /* Subdued text for secondary information */
  --accent: #3aa0ff;  /* Primary accent for important elements */
  --warn: #ffb020;    /* Warning state */
  --danger: #ff4d4f;  /* Danger/alert state */
}

/* Base styles
   ========================================================================== */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: radial-gradient(1200px 800px at 70% 30%, #121926, var(--bg));
  color: var(--fg);
  font-family: system-ui, Segoe UI, Roboto, Inter, Helvetica, Arial, sans-serif;
}

/* Layout
   ========================================================================== */
/* Main container - uses CSS Grid for header, content, footer layout
   Viewport-locked height prevents page scroll, internal elements scroll instead */
.wrap {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto; /* Header, flexible content, footer */
  gap: clamp(0.75rem, 2vh, 2rem);
  padding: 3vh 4vw;
  overflow: hidden; /* Prevents page-level scroll */
}

header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2.2vw + 1rem, 3rem);
  font-weight: 700;
  cursor: pointer;
}

header h1:hover::after {
  content: " ✎";
  opacity: 0.6;
  font-size: 0.8em;
}

header .subtitle {
  color: var(--muted);
  font-size: clamp(0.95rem, 1.2vw + 0.5rem, 1.25rem);
  margin-top: 0.25rem;
  cursor: pointer;
}

header .subtitle:hover::after {
  content: " ✎";
  opacity: 0.6;
}

/* Main content area - Timer and Notes layout
   Uses CSS Grid for vertical layout while allowing notes to scroll */
.main-content {
  display: grid;
  gap: 1rem;
  min-height: 0; /* Allows grid children to shrink */
  grid-template-rows: 1fr;
  align-items: stretch;
}

/* Timer section - Centrally aligned with compact spacing */
.timer {
  display: grid;
  place-items: center;
  gap: 0.2rem; /* Compact spacing between timer elements */
  min-height: 0; /* Allows timer to shrink in grid */
}

.notes {
  min-height: 0;
}

/* Clock display - Large, prominent timer with responsive sizing
   Uses tabular numbers for consistent width and smooth transitions */
.clock {
  font-variant-numeric: tabular-nums; /* Ensures numbers don't shift width */
  font-weight: 800;
  line-height: 1;
  text-align: center;
  letter-spacing: 2px;
  font-size: clamp(5rem, 25vw, 12rem); /* Responsive sizing with limits */
  text-shadow: 0 0 20px rgba(58,160,255,0.18);
  transition: color 0.25s ease, transform 0.18s ease;
}

.clock.warn { color: var(--warn); }
.clock.danger { color: var(--danger); }
.clock.pulse { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); text-shadow: 0 0 16px rgba(255,77,79,0.28); }
  50% { transform: scale(1.02); text-shadow: 0 0 30px rgba(255,77,79,0.5); }
}
.progress-bar-container {
  width: 100%;
  max-width: 600px;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 100%;
  background-color: var(--accent);
  transition: width 0.5s linear, background-color 0.25s ease;
}

.current-datetime {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 600px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.5rem);
  padding: 0 0.6rem;
}

/* Time tracking displays - Elapsed time and overtime
   ========================================================================== */
.time-tracking {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.elapsed-time {
  color: var(--muted);
  font-size: clamp(1rem, 2.2vw, 1.5rem);
  font-variant-numeric: tabular-nums;
}

/* Overtime display - Appears when exam time is exceeded */
.overtime-display {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 1rem;
  background: rgba(255, 77, 79, 0.15);
  border: 2px solid var(--danger);
  border-radius: 12px;
  animation: overtimePulse 2s ease-in-out infinite;
}

.overtime-label {
  font-weight: 700;
  font-size: clamp(0.9rem, 1.8vw, 1.3rem);
  color: var(--danger);
  letter-spacing: 1px;
}

.overtime-value {
  font-weight: 800;
  font-size: clamp(1rem, 2vw, 1.4rem);
  color: var(--danger);
  font-variant-numeric: tabular-nums;
}

@keyframes overtimePulse {
  0%, 100% { 
    box-shadow: 0 0 10px rgba(255, 77, 79, 0.3);
    border-color: var(--danger);
  }
  50% { 
    box-shadow: 0 0 20px rgba(255, 77, 79, 0.6);
    border-color: #ff6b6d;
  }
}

.controls-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* Button styles - Frosted glass effect with hover states
   Consistent styling for interactive elements */
.btn {
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: var(--fg);
  padding: 0.6rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: clamp(0.9rem, 1.2vw + 0.4rem, 1rem);
  cursor: pointer;
  backdrop-filter: blur(4px); /* Frosted glass effect */
}

.btn:hover { background: rgba(255,255,255,0.1); }
.btn.primary {
  border-color: transparent;
  background: var(--accent);
  color: #071018;
}
.btn.primary:hover { filter: brightness(1.05); }

/* Notes section - Scrollable container with frosted glass effect
   Allows internal content to scroll while maintaining viewport-locked layout */
.notes {
  max-width: 1100px;
  margin: 0 auto;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: clamp(1rem, 2.2vw, 1.5rem);
  backdrop-filter: blur(4px);
  position: relative;
  overflow-y: auto; /* Enable internal scrolling */
  min-height: 0; /* Allows proper sizing in grid/flex contexts */
}

.notes h2 {
  margin: 0 0 0.6rem 0;
  font-size: clamp(1.1rem, 1.5vw + 0.5rem, 1.6rem);
}

.notes:hover {
  cursor: pointer;
}

.notes:hover h2::after {
  content: " ✎";
  opacity: 0.6;
}

.rules {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding-left: 1.2rem;
  font-size: clamp(1rem, 1.2vw + 0.5rem, 1.2rem);
}

.rules li { margin: 0.15rem 0; }

.edit-rules-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.edit-rules-btn:hover {
  opacity: 1;
}

footer {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: clamp(0.9rem, 1vw + 0.4rem, 1rem);
}

/* Feature badges - Display key app functionalities */
.footer-features {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.feature-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  font-size: clamp(0.8rem, 0.9vw + 0.3rem, 0.95rem);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  transition: all 0.2s ease;
  cursor: help;
}

.feature-badge:hover {
  border-color: var(--accent);
  background: rgba(58,160,255,0.1);
  color: var(--accent);
}

.pill {
  padding: 0.35rem 0.65rem;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
}

.pill a {
    color: #f5f5dc; 
    text-decoration: none;
}

.pill a:hover {
    text-decoration: underline;
    opacity: 0.9;
}

.kbd {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border: 1px solid rgba(255,255,255,0.2);
  border-bottom-width: 2px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9em;
  background: rgba(255,255,255,0.06);
  color: var(--fg);
}

footer a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

footer a:hover {
  opacity: 0.8;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  place-items: center;
}

.modal.active {
  display: grid;
}

.modal-content {
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
}

.modal-content h2 {
  margin: 0 0 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--muted);
}

.form-group input, .form-group textarea {
  width: 100%;
  padding: 0.8rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--fg);
  font-size: 1rem;
}

.form-group textarea {
  height: 100px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Responsive adjustments
   ========================================================================== */
/* Tighter spacing for very small screens */
@media (max-height: 560px) {
  .wrap {
    padding: 2vh 4vw;
    gap: 1rem;
  }
}