/*
 * Contrast Checker — Web & Chromebook PWA Stylesheet
 * Integrated native window styling for ChromeOS and desktop Chromium browsers.
 */

:root {
  --bg-color: #000000;
  --fg-color: #ffffff;
  --card-bottom-bg: #1d1d20;
  --row-divider: #2a2a2e;
  --label-secondary: #8e8e93;
  --focus-accent: #4cc2ff;
  --toast-green: #34c759;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-rounded: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Consolas", "DejaVu Sans Mono", "Ubuntu Mono", monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: var(--card-bottom-bg);
  color: #ffffff;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

.app-stage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  margin: 0;
}

/* Main Container — Blends seamlessly into window with no rounded corners, border, or shadow */
.contrast-card {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--card-bottom-bg);
  border-radius: 0;
  border: none;
  box-shadow: none;
  overflow: hidden;
  flex: 1 1 auto;
}

/* TOP REGION: Live Background Color Preview & Contrast Ratio */
.top-region {
  position: relative;
  flex: 1 1 auto;
  min-height: 110px;
  width: 100%;
  background-color: var(--bg-color);
  color: var(--fg-color);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  transition: background-color 80ms ease-out, color 80ms ease-out;
}

/* Contrast Ratio Readout (Positioned top-left) */
.ratio-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.contrast-ratio-btn {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--fg-color);
  cursor: pointer;
  text-align: left;
}

.contrast-ratio-text {
  display: block;
  font-family: var(--font-rounded);
  font-size: 40px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.5px;
  color: var(--fg-color);
}

.contrast-ratio-subtitle {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--fg-color);
  opacity: 0.75;
  margin-top: 2px;
}

/* BOTTOM REGION: Pickers, Swatches, and HEX Readouts */
.bottom-region {
  flex: 0 0 auto;
  width: 100%;
  background-color: var(--card-bottom-bg);
  padding: 18px 24px 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 32px;
  width: 100%;
}

/* Eyedropper Scope Button */
.scope-button {
  width: 30px;
  height: 30px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.09);
  color: #e0e0e0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 120ms ease, transform 80ms ease;
}

.scope-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.scope-button:active {
  background: rgba(255, 255, 255, 0.28);
}

/* Color Swatch Circle + Hidden Native Color Input */
.swatch-wrapper {
  position: relative;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: background-color 80ms ease-out;
}

#bg-swatch {
  background-color: var(--bg-color);
}

#fg-swatch {
  background-color: var(--fg-color);
}

.native-color-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
}

/* Clickable HEX Code Button */
.hex-button {
  background: transparent;
  border: none;
  padding: 2px 4px;
  margin: 0 -4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.hex-text {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.row-spacer {
  flex: 1 1 auto;
}

.row-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--label-secondary);
}

/* Subtle Divider Line */
.row-divider {
  height: 1px;
  background-color: var(--row-divider);
  margin: 10px 0;
  width: 100%;
}

/* TOAST NOTIFICATION OVERLAY */
.toast-overlay {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(44, 44, 48, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
  animation: toast-in 180ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.toast-overlay[hidden] {
  display: none !important;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

.toast-check {
  color: var(--toast-green);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}

.toast-text {
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

/* PWA Install Button (shown only when browser fires beforeinstallprompt) */
.pwa-install-banner {
  position: fixed;
  bottom: 14px;
  right: 18px;
  z-index: 20;
}

.pwa-install-banner[hidden] {
  display: none !important;
}

.install-pwa-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #e5e5ea;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.install-pwa-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
}

/* ACCESSIBLE DUAL-LAYER KEYBOARD FOCUS RINGS */
button:focus {
  outline: none;
}

.circle-focus:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--focus-accent),
    0 0 0 4px rgba(0, 0, 0, 0.65);
}

.rect-focus:focus-visible {
  outline: none;
  border-radius: 5px;
  box-shadow:
    0 0 0 2px var(--focus-accent),
    0 0 0 4px rgba(0, 0, 0, 0.65);
}
