/* ========================================
   DESIGN TOKENS
   ======================================== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a28;
  --bg-ruler: #0e0e18;
  --surface-glass: rgba(255, 255, 255, 0.04);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);

  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55556a;

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

  --tick-major: rgba(255, 255, 255, 0.85);
  --tick-half: rgba(255, 255, 255, 0.45);
  --tick-minor: rgba(255, 255, 255, 0.2);
  --tick-label: rgba(255, 255, 255, 0.7);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --header-height: 60px;

  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ========================================
   RESET & BASE
   ======================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow-x: hidden;
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden {
  display: none !important;
}

/* ========================================
   SPLASH OVERLAY (Mobile Fullscreen)
   ======================================== */
.splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.splash-content {
  text-align: center;
  padding: 40px;
}

.splash-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

.splash-content h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.splash-content p {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 32px;
  max-width: 280px;
}

.splash-btn {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto 16px;
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #fff;
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 24px var(--accent-glow);
}

.splash-btn:active {
  transform: scale(0.97);
}

.splash-skip {
  display: block;
  margin: 0 auto;
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s;
}

.splash-skip:hover {
  color: var(--text-secondary);
}

/* ========================================
   APP CONTAINER
   ======================================== */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ========================================
   TOP BAR
   ======================================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 24px;
}

.logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Nav link to distance tracker */
.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-glass);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: all 0.2s;
}

.nav-link:hover {
  border-color: var(--border-glow);
  color: var(--accent-light);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 16px var(--accent-glow);
}

/* Unit Switch Toggle */
.unit-switch {
  position: relative;
  display: flex;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border-subtle);
}

.unit-btn {
  position: relative;
  z-index: 2;
  padding: 6px 18px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: color 0.3s;
  border-radius: 6px;
}

.unit-btn.active {
  color: #fff;
}

.unit-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: var(--accent-gradient);
  border-radius: 6px;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.unit-slider.right {
  transform: translateX(100%);
}

/* Fullscreen button */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn:hover {
  border-color: var(--border-glow);
  color: var(--accent-light);
  background: rgba(99, 102, 241, 0.08);
}

/* ========================================
   RULER AREA
   ======================================== */
.ruler-area {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Ruler strip (left side) */
.ruler-strip {
  width: 80px;
  flex-shrink: 0;
  background: var(--bg-ruler);
  border-right: 1px solid var(--border-subtle);
  position: relative;
  overflow: hidden;
  cursor: ns-resize;
}

.ruler-strip::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(
    to bottom,
    transparent,
    var(--accent) 20%,
    var(--accent) 80%,
    transparent
  );
  opacity: 0.4;
}

#ruler-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Center content */
.center-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

/* Decorative background grid */
.center-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 1px, transparent 0);
  background-size: 32px 32px;
  pointer-events: none;
}

/* Decorative glow */
.center-content::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
  opacity: 0.15;
  pointer-events: none;
}

.measure-info {
  position: relative;
  z-index: 1;
  text-align: center;
}

.current-length {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -3px;
  line-height: 1;
  background: linear-gradient(180deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: opacity 0.2s;
}

.current-unit {
  font-size: 18px;
  font-weight: 500;
  color: var(--accent-light);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 4px;
}

.hint-text {
  position: relative;
  z-index: 1;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 12px;
  animation: pulse 3s ease-in-out infinite;
}

.dpi-info {
  position: absolute;
  bottom: 16px;
  right: 16px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */
@media (max-width: 600px) {
  :root {
    --header-height: 52px;
  }

  .top-bar {
    padding: 0 12px;
  }

  .logo-text {
    font-size: 17px;
  }

  .logo-icon {
    font-size: 20px;
  }

  .unit-btn {
    padding: 5px 14px;
    font-size: 11px;
  }

  .icon-btn {
    width: 34px;
    height: 34px;
  }

  .nav-link span {
    display: none;
  }

  .nav-link {
    padding: 6px 8px;
  }

  .ruler-strip {
    width: 60px;
  }

  .current-length {
    font-size: 56px;
  }

  .current-unit {
    font-size: 15px;
  }

  .hint-text {
    font-size: 12px;
  }
}

@media (max-width: 360px) {
  .ruler-strip {
    width: 50px;
  }

  .current-length {
    font-size: 44px;
  }

  .unit-btn {
    padding: 4px 10px;
    font-size: 10px;
  }
}

/* Landscape on mobile */
@media (max-height: 500px) {
  :root {
    --header-height: 44px;
  }

  .current-length {
    font-size: 48px;
  }

  .logo-text {
    font-size: 16px;
  }
}

/* ========================================
   SCROLLBAR (for touch devices that show it)
   ======================================== */
.app-container ::-webkit-scrollbar {
  display: none;
}

.app-container * {
  scrollbar-width: none;
}

/* ========================================
   SEO CONTENT SECTION
   ======================================== */
.seo-content {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 64px 24px 80px;
  user-select: text;
  -webkit-user-select: text;
  touch-action: auto;
}

.seo-inner {
  max-width: 780px;
  margin: 0 auto;
}

.seo-content h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.25;
  margin-bottom: 20px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.seo-content h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-top: 40px;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.seo-intro {
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.seo-content p {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.seo-content ul,
.seo-content ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.seo-content li {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.seo-content li strong {
  color: var(--text-primary);
}

.seo-content kbd {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-light);
}

.seo-content hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 48px 0;
}

/* FAQ Accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.25s;
}

.faq-item[open] {
  border-color: var(--border-glow);
}

.faq-item summary {
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color 0.2s;
}

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

.faq-item summary::after {
  content: '+';
  font-size: 20px;
  font-weight: 300;
  color: var(--text-muted);
  transition: transform 0.25s;
}

.faq-item[open] summary::after {
  content: '−';
  color: var(--accent-light);
}

.faq-item summary:hover {
  color: var(--accent-light);
}

.faq-item > p,
.faq-item > ol {
  padding: 0 20px 16px;
  margin: 0;
}

/* SEO Responsive */
@media (max-width: 600px) {
  .seo-content {
    padding: 40px 16px 60px;
  }

  .seo-content h1 {
    font-size: 24px;
  }

  .seo-content h2 {
    font-size: 18px;
    margin-top: 32px;
  }

  .seo-intro {
    font-size: 15px;
  }

  .seo-content p,
  .seo-content li {
    font-size: 14px;
  }

  .faq-item summary {
    font-size: 14px;
    padding: 14px 16px;
  }
}

/* ========================================
   SITE FOOTER
   ======================================== */
.site-footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-subtle);
  padding: 48px 24px 40px;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
  touch-action: auto;
}

.footer-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-logo {
  font-size: 22px;
}

.footer-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
}

.footer-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
  padding: 4px 0;
}

.footer-link:hover {
  color: var(--accent-light);
}

.footer-copy {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

@media (max-width: 600px) {
  .site-footer {
    padding: 36px 16px 32px;
  }

  .footer-nav {
    gap: 6px 16px;
  }

  .footer-link {
    font-size: 13px;
  }

  .footer-copy {
    font-size: 12px;
  }
}

/* ========================================
   UTILITIES
   ======================================== */
.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-light);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 10px 6px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
}

.back-link:hover {
  background: rgba(99, 102, 241, 0.1);
  color: #a5b4fc;
}

.back-link svg {
  display: block;
}

