html {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

html {
  scroll-behavior: smooth;
}

h2 {
  font-size: 24px;
  margin-bottom: 50px;
  color: #010024;
}

body {
  font-family: 'Roboto', sans-serif;
  margin: 0;
  padding: 0;
  background-color: #ffffff;
  color: #000000;
}

/* Navigation Menu */
.main-nav {
  background-color: #fff;
  padding: 15px 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 999;
}

.nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 900px;
  margin: 0 auto;
}

.nav-logo {
  font-weight: bold;
  color: #010024;
  font-size: 18px;
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-links a {
  text-decoration: none;
  color: #010024;
  font-weight: bold;
  font-size: 16px;
  transition: color 0.3s ease;
}

.nav-links a:hover {
  color: #ff6700;
}

.hamburger {
  display: none;
  font-size: 26px;
  cursor: pointer;
  color: #010024;
  background: none;
  border: none;
}

@media (max-width: 900px) {
  .nav-links {
    flex-direction: column;
    background-color: #fff;
    position: absolute;
    top: 60px;
    right: 20px;
    width: 200px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    padding: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  }

  .nav-links.active {
    padding: 15px;
    max-height: 500px;
    opacity: 1;
  }

  .hamburger {
    display: block;
  }
}

/* Hero Section */
.hero-section {
  position: relative;
  width: 100%;
  height: 300px;
  overflow: hidden;
  margin-bottom: -40px;
  /* Overlap with content */
  z-index: 0;
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.8;
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, transparent, var(--bg-color));
}

/* Content Layout */
.text-container {
  position: relative;
  z-index: 1;
  /* Above hero */
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

h1 {
  color: #010024;
}

p {
  line-height: 1.6;
  color: #010024;
}

/*Buttons calculators*/
/* Tab Button Styling */
.tab-btn {
  background-color: #d2d2d9;
  /* Button background color */
  color: #f7f7fc;
  /* Button text color */
  border: none;
  padding: 0px 10px;
  cursor: pointer;
  border-radius: 5px;
  transition: background-color 0.3s ease;
}

.tab-btn:hover {
  background-color: #4e4e69;
  /* Hover state */
}

.tab-btn:active {
  background-color: #3a3a7a;
  /* Click/press state */
  transform: scale(0.98);
  /* Slight press effect */
}

.tab-btn.active {
  background-color: #1c1c6b;
  /* Active/selected state */
}


/* Category tabs styled as links */
.category-tabs {
  display: flex;
  gap: 25px;
  justify-content: center;
  margin-bottom: 20px;
}

.category-tabs .tab-btn {
  background-color: transparent;
  color: #d2d2d9;
  padding: 5px 0;
  border-radius: 0;
  transition: color 0.3s ease;
}

.category-tabs .tab-btn:hover {
  background-color: transparent;
  color: #ff6700;
  text-decoration: underline;
}

.category-tabs .tab-btn:active {
  background-color: transparent;
  transform: none;
}

.category-tabs .tab-btn.active {
  background-color: transparent;
  color: #1c1c6b;
  font-weight: bold;
  text-decoration: none;
}



/* Timer Tool Styles */
#timer-container {
  font-family: Arial, sans-serif;
  text-align: center;
  margin: 80px auto;
}

#timer-container h2 {
  margin-bottom: 20px;
}

.timer-display-row {
  margin-bottom: 20px;
}

#timer-display {
  font-size: 3em;
  padding: 20px;
  border-radius: 10px;
  background: #000;
  color: #0f0;
  transition: all 0.6s ease-in-out;
  display: inline-block;
}

.green {
  color: #0f0;
}

.orange {
  color: orange;
}

.red {
  color: red;
}

.flash {
  color: red;
  animation: flash 1s infinite;
}

@keyframes flash {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

#timer-display:fullscreen {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20vw;
  background: #000;
  transform: scale(1.1);
}

.timer-button-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

button {
  font-size: 1em;
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  transition: background 0.3s ease;
}

/* Calculator buttons */
.calc-btn {
  background: #1c1c6b;
}

.calc-btn:hover {
  background: #151554;
}

button[type="submit"] {
  background: #28a745;
}

button[type="submit"]:hover {
  background: #218838;
}

#timer-stop {
  background: #dc3545;
}

#timer-stop:hover {
  background: #c82333;
}

#timer-load {
  background: #007bff;
}

#timer-load:hover {
  background: #0069d9;
}

#timer-fullscreen {
  background: #000;
}

#timer-fullscreen:hover {
  background: #333;
}

.timer-input-row,
.timer-settings-row {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 15px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.9em;
}

#timer-display.green {
  color: #0f0;
}

#timer-display.orange {
  color: orange;
}

#timer-display.red {
  color: red;
}

/* Count down  */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

table,
th,
td {
  border: 1px solid #ccc;
}

th,
td {
  padding: 10px;
  text-align: left;
}

ul {
  list-style-type: disc;
  margin-left: 20px;
}

/* Base layout: horizontal rows */
.timer-input-row,
.timer-settings-row,
.timer-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

/* Inputs and buttons default */
.timer-input-row label,
.timer-settings-row label {
  flex: 1 1 auto;
  min-width: 120px;
}

.timer-button-row button {
  padding: 0.5rem 1rem;
}

/* Responsive adjustments for mobile */
@media (max-width: 600px) {

  .timer-input-row,
  .timer-settings-row,
  .timer-button-row {
    flex-direction: column;
    align-items: stretch;
  }

  .timer-input-row label,
  .timer-settings-row label {
    width: 100%;
  }

  .timer-button-row button {
    width: 100%;
  }

  #timer-display {
    font-size: 2rem;
    /* make digits large and readable */
    text-align: center;
  }
}


#timer-display {
  text-align: center;
  font-weight: bold;
  /* Scale font size based on screen width */
  font-size: clamp(2rem, 10vw, 6rem);
}

/* ==========================================
   AR PAGE STYLES
   ========================================== */

/* Prevent layout overflow on AR pages (mobile) */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* When viewing AR, keep the viewport fixed to avoid scrolling and layout jumps */
body.ar-page {
  overflow: hidden;
  touch-action: manipulation;
}


/* AR-specific body override */
body.ar-page {
  margin: 0;
  /* Use webkit-fill-available for iOS safari and fallbacks */
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  position: relative;
  /* Prevent scroll bounce */
  overscroll-behavior: none;
  background-color: #000000 !important;
  /* Pitch black for cinema bars */
}

#arjs-video {
  /* Video Background Layer - center and lock to viewport to avoid page shifts */
  z-index: 10 !important;
  position: fixed !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  max-height: 100dvh !important;
  object-fit: contain !important;
  margin: 0 !important;
}

.a-canvas,
body.ar-page canvas {
  /* 3D Foreground Layer (Must be higher!) */
  z-index: 20 !important;
  position: fixed !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: 100vw !important;
  max-height: 100dvh !important;
  object-fit: contain !important;
  margin: 0 !important;
}

.arjs-loader {
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  /* Ensure it covers everything on mobile */
  min-height: 100dvh;
}

.arjs-loader div {
  text-align: center;
  font-size: 1.25em;
  color: white;
}

/* UI Overlay */
.ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  pointer-events: none;
}

/* AR page nav pointer events */
.ar-page .main-nav {
  pointer-events: auto;
  /* FIX: Decouple from body width (which AR.js stretches) */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  max-width: 100vw;
  /* Ensure no padding adds to width (handled by global box-sizing, but safe to be explicit) */
  box-sizing: border-box;
  /* Boost z-index to ensure visibility over AR video/canvas */
  z-index: 10001 !important;
}

/* Mobile Dropdown Override for AR Page */
@media (max-width: 900px) {
  .ar-page .nav-links {
    background-color: rgba(255, 255, 255, 0.95);
    /* Keep dropdown white/readable */
  }

  /* Reset link color inside the white mobile dropdown */
  .ar-page .nav-links a {
    color: #010024;
    text-shadow: none;
  }
}

/* AR Instructions */
.ar-instructions {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: transparent;
  color: white;
  z-index: 999;
  pointer-events: none;
  max-width: 90vw;
}

/* Info Toggle Button */
#info-toggle {
  position: fixed;
  /* Move to bottom-right or top-right depending on preference, 
      but relative to safe area */
  top: calc(80px + env(safe-area-inset-top));
  right: 20px;
  z-index: 10000;
  background: #dc3545;
  /* Red "Hide" state by default */
  color: white;
  border: none;
  border-radius: 30px;
  padding: 12px 20px;
  /* Larger touch target */
  font-size: 1em;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  font-weight: bold;
  /* Ensure minimum touch target size */
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Black state when info is hidden */
#info-toggle.btn-black {
  background: #000000 !important;
}

/* Project Info Panel */
#project-info {
  position: fixed;
  /* Use safe area insets */
  top: calc(60px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  background: white;
  /* Use dvh for dynamic viewport height */
  max-height: calc(85dvh - 60px);
  overflow-y: auto;
  z-index: 998;
  transition: transform 0.4s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  /* Safe area for content inside */
  padding-bottom: env(safe-area-inset-bottom);
}

.project-info-content {
  padding: 30px 20px;
  max-width: 900px;
  margin: 0 auto;
}

.project-info-content h1 {
  color: #010024;
  margin-bottom: 20px;
}

.ar-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

.ar-grid-2col h2 {
  font-size: 1.3em;
  color: #010024;
  margin-bottom: 15px;
}

.ar-grid-2col h3 {
  font-size: 1.1em;
  color: #010024;
  margin-top: 20px;
  margin-bottom: 10px;
}

.ar-grid-2col p {
  line-height: 1.6;
  color: #010024;
}

.ar-grid-2col ul {
  line-height: 1.8;
  color: #010024;
}

/* Dice Photo Placeholder */
.dice-photo-placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: #f0f0f0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #ccc;
}

.dice-photo-placeholder span {
  color: #999;
  font-size: 0.9em;
}

/* Camera Access Info Box */
.camera-access-box {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.camera-access-box h3 {
  font-size: 1.1em;
  color: #010024;
  margin-top: 0;
  margin-bottom: 10px;
}

.camera-access-box p {
  line-height: 1.6;
  color: #010024;
  margin: 0;
}

/* AR Steps Grid */
.ar-steps-grid {
  display: grid;
  /* Smaller minmax for mobile screens */
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}

.ar-step-card {
  background: #e8f4f8;
  padding: 15px;
  border-radius: 8px;
}

.ar-step-card strong {
  color: #010024;
  display: block;
  margin-bottom: 8px;
}

.ar-step-card p {
  margin: 0;
  line-height: 1.5;
  color: #010024;
  font-size: 0.95em;
}

/* AR Close Info Box */
.ar-close-info {
  text-align: center;
  padding: 20px;
  background: #f0f0f0;
  border-radius: 8px;
}

.ar-close-info p {
  color: #010024;
  margin: 0;
  font-weight: bold;
}

/* AR Instructions Box */
.ar-instructions-box {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(0, 0, 0, 0.85);
  padding: 15px;
  border-radius: 12px;
  max-width: 90vw;
  pointer-events: auto;
}

.ar-instructions-box img {
  width: 80px;
  height: 80px;
  border: 2px solid white;
  border-radius: 4px;
}

.ar-instructions-text {
  text-align: left;
}

.ar-instructions-text strong {
  display: block;
  margin-bottom: 5px;
  color: var(--secondary-color);
}

.ar-instructions-text span {
  font-size: 0.9em;
  opacity: 0.9;
}

/* Camera Error Box */
.camera-error-box {
  background: rgba(220, 53, 69, 0.9);
  padding: 15px;
  border-radius: 12px;
  max-width: 90vw;
  pointer-events: auto;
  border: 2px solid #ff6b6b;
}

.camera-error-content {
  text-align: center;
}

.camera-error-content strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.1em;
}

.camera-error-content span {
  font-size: 0.9em;
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */

.hidden {
  display: none !important;
}

.main-tool-tabs {
  margin-bottom: 30px;
  justify-content: center;
  display: flex;
  gap: 15px;
}

.chat-spacer {
  margin-top: 60px;
}