/* ==========================================================================
   Dice Roller - Main Styles
   BEM methodology
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties - Dieter Rams inspired (drams.framer.website)
   -------------------------------------------------------------------------- */
:root {
  /* Clean minimal palette */
  --color-bg: #262626;
  --color-surface: #ffffff;
  --color-surface-alt: #f7f7f7;
  --color-accent: #ff611a; /* Vibrant Rams orange */
  --color-accent-hover: #e55515;
  --color-text: #262626;
  --color-text-muted: #4f4f4f;
  --color-border: rgba(124, 114, 83, 0.75);

  /* Clean geometric typography */
  --font-family: "Space Mono", monospace;
  --font-size-base: 0.875rem;
  --font-size-sm: 0.75rem;
  --font-size-lg: 1rem;
  --font-size-xl: 1.5rem;

  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Minimal radii */
  --radius-sm: 4px;
  --radius-md: 4px;
  --radius-lg: 8px;
  --radius-pill: 100px;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;

  --bottom-nav-height: 85.4px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* --------------------------------------------------------------------------
   Reset and Base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Button reset */
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* Input reset */
input,
select {
  font: inherit;
  color: inherit;
}

/* --------------------------------------------------------------------------
   App Layout
   -------------------------------------------------------------------------- */
.app {
  position: fixed;
  inset: 0;
  bottom: var(--bottom-nav-height);
}

/* --------------------------------------------------------------------------
   Dice Scene - 3D Canvas Area (full screen)
   -------------------------------------------------------------------------- */
.dice-scene {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: var(--color-surface);
  overflow: hidden;
  /* Indicate swipeable area */
  touch-action: none;
}

.dice-scene__canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.dice-scene__canvas:active {
  cursor: grabbing;
}

/* Roll result overlay - clean Rams style */
.dice-scene__result {
  position: absolute;
  top: var(--spacing-xl);
  left: 50%;
  transform: translateX(-50%);
  background-color: #f5f0e6; /* Ivory */
  color: var(--color-text);
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xl);
  font-weight: 500;
  letter-spacing: -0.03em;
  min-width: 64px;
  text-align: center;
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--color-border);
}

.dice-scene__result:not(:empty) {
  opacity: 1;
}

.dice-scene__credit {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  font-size: var(--font-size-sm);
  color: rgba(0, 0, 0, 0.3);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.dice-scene__credit:hover {
  color: rgba(0, 0, 0, 0.5);
}

/* --------------------------------------------------------------------------
   Bottom Navigation - Dieter Rams inspired (drams.framer.website)
   -------------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #f5f0e6;
  padding: var(--spacing-sm) var(--spacing-md);
  padding-bottom: calc(var(--spacing-sm) + var(--safe-area-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  border-top: 1px solid var(--color-border);
}

.bottom-nav__row {
  display: flex;
  width: 100%;
}

/* Count buttons (1-10) - modern Braun/Rams style */
.count-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1vw, 8px);
  width: 100%;
}

.count-button {
  flex: 1;
  aspect-ratio: 1;
  max-width: 36px;
  max-height: 36px;
  border-radius: 50%;
  background-color: #e8e3d6; /* Darker ivory */
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.count-button:hover {
  background-color: #ddd8cb;
  color: var(--color-text);
}

.count-button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.count-button--active {
  background-color: var(--color-text);
  color: var(--color-surface);
  border-color: var(--color-text);
}

/* Color swatches - modern Braun/Rams style */
.color-swatches {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1vw, 8px);
  width: 100%;
}

.color-swatch {
  flex: 1;
  aspect-ratio: 1;
  max-width: 36px;
  max-height: 36px;
  border-radius: 50%;
  background-color: var(--swatch-color);
  border: 1px solid rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.color-swatch--active {
  border-color: var(--color-text);
}

.color-swatch--random {
  border-color: #87827a;
}

/* Random swatch - multi-color gradient */
.color-swatch--random {
  background: linear-gradient(
    135deg,
    #e07860 0%,
    #d4a03c 25%,
    #8fa882 50%,
    #4a8f8f 75%,
    #2c3e5a 100%
  );
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Responsive Adjustments
   -------------------------------------------------------------------------- */

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