/**
 * Feelings Wheel Main Stylesheet
 */

/* ========================================
   CSS RESET & BASE
   ======================================== */

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

* {
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
}

body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--fg);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

main a {
  color: var(--link-color);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

main a:hover {
  text-decoration: underline;
}

/* ========================================
   LAYOUT
   ======================================== */

header {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-md);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md);
  gap: var(--space-lg);
}

footer {
  padding: var(--space-md);
  text-align: center;
}

/* ========================================
   WHEEL CONTAINER
   ======================================== */

#wheel-container {
  width: 100%;
  max-width: min(92vh, 92vw);
  aspect-ratio: 1 / 1;
  position: relative;
  margin: 0 auto;
}

#wheel {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none; /* Prevent scroll while pinch-zooming */
}

/* ========================================
   WEDGE STYLES
   ======================================== */

.wedge {
  cursor: pointer;
  transition: opacity var(--transition-normal) ease;
}

.wedge path {
  stroke: var(--wedge-border);
  stroke-width: 1px;
  fill: hsl(var(--wedge-hue), var(--tier-sat), var(--wedge-l));
  transition: fill var(--transition-normal) ease,
              stroke var(--transition-normal) ease;
}

.wedge:hover path {
  stroke-width: 2px;
}

.wedge:focus {
  outline: none;
}

.wedge:focus path {
  stroke: var(--focus-ring);
  stroke-width: var(--focus-ring-width);
}

.wedge[data-selected="true"] path {
  stroke: var(--focus-ring);
  stroke-width: var(--focus-ring-width);
}

/* All three tiers are always rendered and visible. */
.tier-group {
  transform-origin: center;
}

#tier-1,
#tier-2,
#tier-3 {
  opacity: 1;
}

/* Unselected wedges dim when a selection exists on the wheel. */
#wheel[data-has-selection="true"] .wedge:not([data-selected="true"]) path {
  opacity: 0.55;
}

footer {
  padding: var(--space-md);
  text-align: center;
  color: var(--fg);
  opacity: 0.7;
  font-size: 14px;
}
.footer-sep {
  margin: 0 var(--space-sm);
  opacity: 0.5;
}
.footer-version {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 13px;
}

/* Spin interactions */
#wheel {
  touch-action: none;
  cursor: grab;
}
#wheel.spinning {
  cursor: grabbing;
}

/* ========================================
   WEDGE LABELS
   ======================================== */

.wedge-label {
  font-size: clamp(12px, 2vw, 18px);
  font-weight: 500;
  fill: var(--label-text);
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: middle;
  user-select: none;
}

.tier-1 .wedge-label {
  font-size: clamp(14px, 2.5vw, 22px);
  font-weight: 600;
}

.tier-3 .wedge-label {
  font-size: clamp(11px, 1.5vw, 14px);
}

/* ========================================
   BREADCRUMB
   ======================================== */

#breadcrumb {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.breadcrumb-item button {
  background: var(--button-bg);
  color: var(--button-fg);
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: 4px;
  font-size: clamp(14px, 2vw, 16px);
  transition: background-color var(--transition-fast) ease;
}

.breadcrumb-item button:hover {
  background: var(--button-hover-bg);
}

.breadcrumb-separator {
  color: var(--fg);
  opacity: 0.5;
}

/* ========================================
   ZOOM CONTROLS
   ======================================== */

#controls {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

#controls button {
  background: var(--button-bg);
  color: var(--button-fg);
  border: 1px solid var(--border-color);
  padding: var(--space-sm) var(--space-md);
  border-radius: 4px;
  font-size: 18px;
  min-width: 44px;
  min-height: 44px;
  transition: background-color var(--transition-fast) ease;
}

#controls button:hover {
  background: var(--button-hover-bg);
}

/* ========================================
   ABOUT PAGE
   ======================================== */

main h1 {
  font-size: clamp(28px, 6vw, 48px);
  margin-bottom: var(--space-lg);
  text-align: center;
}

main section {
  max-width: 700px;
  margin: 0 auto var(--space-xl);
  padding: var(--space-lg);
  background: var(--button-bg);
  border-radius: 8px;
}

main h2 {
  font-size: clamp(22px, 4vw, 32px);
  margin-bottom: var(--space-md);
}

main p {
  margin-bottom: var(--space-md);
  line-height: 1.7;
}

main ul {
  margin-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

main li {
  margin-bottom: var(--space-sm);
}

/* ========================================
   OUTCOME PANEL
   ======================================== */

#outcome {
  text-align: center;
  padding: var(--space-lg);
  background: var(--button-bg);
  border-radius: 8px;
  max-width: 600px;
  width: 100%;
}

#outcome h2 {
  font-size: clamp(24px, 5vw, 36px);
  margin-bottom: var(--space-md);
}

#outcome p {
  font-size: clamp(16px, 3vw, 18px);
  margin-bottom: var(--space-lg);
  opacity: 0.9;
}

#copy-link {
  background: var(--button-bg);
  color: var(--button-fg);
  border: 1px solid var(--border-color);
  padding: var(--space-sm) var(--space-lg);
  border-radius: 4px;
  font-size: 16px;
  transition: background-color var(--transition-fast) ease;
}

#copy-link:hover {
  background: var(--button-hover-bg);
}

#copy-link:active {
  transform: scale(0.98);
}

/* ========================================
   THEME TOGGLE
   ======================================== */

#theme-toggle {
  background: var(--button-bg);
  color: var(--button-fg);
  border: 1px solid var(--border-color);
  padding: var(--space-sm);
  border-radius: 4px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (width >= 768px) {
  main {
    padding: var(--space-lg);
  }

  #wheel-container {
    max-width: 60vh;
  }
}

@media (width >= 1024px) {
  #wheel-container {
    max-width: min(92vh, 92vw);
  }
}
