/* ============================================
   App Layout — ld-color-tool specific
   Depends on: neo-brutalist/brutalist.css
   ============================================ */

/* ---------- Page ---------- */
body {
  background: var(--nb-bg);
  font-family: var(--nb-font-heading);
  color: var(--nb-ink);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

.page-header {
  text-align: center;
  padding: var(--nb-space-xl) var(--nb-space-md) var(--nb-space-md);
  max-width: 960px;
  margin: 0 auto;
}

.page-title {
  font-family: var(--nb-font-heading);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1.5px;
  color: var(--nb-ink);
  margin: 0 0 var(--nb-space-xs);
}

.page-description {
  font-family: var(--nb-font-heading);
  font-size: 14px;
  color: var(--nb-ink-muted);
  margin: 0;
  line-height: 1.5;
}

/* ---------- Bento Grid ---------- */
.bento {
  display: grid;
  grid-template-columns: 280px 1fr 1fr;
  gap: var(--nb-grid-gap);
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--nb-space-md) var(--nb-space-xl);
}

.bento-picker {
  grid-row: span 2;
}

.bento-adjust {
  grid-column: span 2;
}

.bento-outputs {
  grid-column: span 2;
}

.bento-harmonies {
  grid-column: span 2;
}

.bento-shades {
  grid-row: span 2;
}

/* ---------- Card Internals ---------- */
.picker-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: var(--nb-space-md);
  height: 100%;
}

.picker-wheel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--nb-space-sm) 0;
}

.picker-wheel reinvented-color-wheel {
  border-radius: 50%;
}

.picker-inputs {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--nb-space-sm);
  border-top: var(--nb-border-sm);
  padding-top: var(--nb-space-md);
}

.picker-input-row {
  display: flex;
  gap: var(--nb-space-sm);
  align-items: flex-end;
  min-height: 57px;
}

.picker-format-select {
  flex-shrink: 0;
  padding-left: 10px;
  padding-right: 22px;
  font-size: 13px;
  background-position: right 6px center;
}

.picker-input-area {
  flex: 1;
  display: flex;
  gap: var(--nb-space-xs);
  min-width: 0;
}

.picker-input-area .nb-input {
  flex: 1;
  min-width: 0;
  padding: 8px 8px;
  font-size: 13px;
  text-align: left;
  -moz-appearance: textfield;
  appearance: textfield;
}

.picker-input-area .nb-input::-webkit-outer-spin-button,
.picker-input-area .nb-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.picker-channel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.picker-channel__label {
  font-family: var(--nb-font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--nb-ink-muted);
  text-align: center;
  line-height: 1;
}

.picker-channel .nb-input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 4px;
  font-size: 13px;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

.picker-channel .nb-input::-webkit-outer-spin-button,
.picker-channel .nb-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.adjust-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--nb-space-sm);
}

.adjust-header .nb-card-label {
  margin-bottom: 0;
}

.nb-btn--reset {
  padding: 6px 8px;
  min-height: 32px;
  min-width: 32px;
  background: var(--nb-surface);
  border: var(--nb-border-sm);
}

.nb-btn--reset:hover {
  background: #f0f0f0;
}

.adjust-layout {
  display: flex;
  flex-direction: column;
  gap: var(--nb-space-md);
}

.adjust-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: var(--nb-space-sm);
}

.slider-row .nb-slider {
  flex: 1;
}

.slider-row .nb-input {
  width: 81px;
  flex-shrink: 0;
}

.outputs-layout {
  display: flex;
  flex-direction: column;
  gap: var(--nb-space-sm);
}

.contrast-layout {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: var(--nb-space-md);
  height: 100%;
}

.contrast-previews {
  display: flex;
  gap: var(--nb-space-sm);
}

.contrast-box {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--nb-space-md);
  border: var(--nb-border-sm);
  box-shadow: var(--nb-shadow-sm);
  font-family: var(--nb-font-heading);
  font-size: 14px;
  font-weight: 700;
}

.contrast-ratio {
  text-align: center;
  font-family: var(--nb-font-mono);
  font-size: 28px;
  font-weight: 700;
}

.contrast-badges {
  display: flex;
  gap: var(--nb-space-sm);
}

.contrast-badges .nb-badge {
  flex: 1;
  text-align: center;
  justify-content: center;
}

.contrast-bg-row {
  display: flex;
  align-items: center;
  gap: var(--nb-space-sm);
}

.contrast-bg-row label {
  font-family: var(--nb-font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--nb-ink-muted);
  white-space: nowrap;
}

.contrast-bg-row .nb-input {
  flex: 1;
}

.harmonies-layout {
  display: flex;
  flex-direction: column;
  gap: var(--nb-space-md);
}

.harmony-section {
  display: flex;
  flex-direction: column;
  gap: var(--nb-space-xs);
}

.harmony-type {
  font-family: var(--nb-font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--nb-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.harmony-swatches {
  display: flex;
  gap: var(--nb-space-xs);
}

.harmony-swatches .nb-swatch {
  flex: 1;
  height: 40px;
}

.shades-layout {
  display: flex;
  flex-direction: column;
  gap: var(--nb-space-md);
  height: 100%;
  padding-bottom: var(--nb-space-lg);
}

/* Vertical shade strip on desktop — each step full-width of col, stacked. */
.bento-shades .nb-shade-strip {
  flex: 1;
  flex-direction: column;
}

.bento-shades .nb-shade-step {
  flex-direction: row;
  justify-content: space-between;
  padding: 10px 14px;
  border-right: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  min-height: 40px;
}

.bento-shades .nb-shade-step:last-child {
  border-bottom: none;
}

.bento-shades .nb-shade-step:hover {
  transform: translateX(2px);
}

.bento-shades .nb-shade-step__num {
  font-size: 12px;
}

.bento-shades .nb-shade-step__hex {
  font-size: 11px;
}

/* ---------- Spin Wheel Card ---------- */
.spin-layout {
  display: flex;
  flex-direction: column;
  gap: var(--nb-space-md);
  align-items: center;
}

.spin-layout .nb-select {
  width: 100%;
}

.spin-wheel-frame {
  position: relative;
  width: 100%;
  max-width: 240px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spin-wheel {
  width: clamp(180px, 100%, 240px);
  height: auto;
  display: block;
  transition: transform 3s cubic-bezier(0.17, 0.67, 0.12, 1);
  will-change: transform;
  border-radius: 50%;
  border: var(--nb-border-sm);
  background: var(--nb-surface);
}

.spin-wheel path {
  stroke: var(--nb-ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

.spin-pointer {
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 20px solid var(--nb-ink);
  z-index: 2;
  pointer-events: none;
}

.spin-button {
  width: 100%;
  background: var(--nb-accent-3);
}

.spin-button:disabled,
.spin-layout .nb-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Responsive: Tablet ---------- */
@media (max-width: 959px) {
  .bento {
    grid-template-columns: 1fr 1fr;
  }

  .bento-picker {
    grid-column: span 2;
    grid-row: span 1;
  }

  .bento-adjust {
    grid-column: span 1;
  }

  .bento-outputs {
    grid-column: span 1;
  }

  .bento-contrast {
    grid-column: span 1;
  }

  .bento-harmonies {
    grid-column: span 2;
  }

  .bento-spin {
    grid-column: span 1;
  }

  .bento-shades {
    grid-column: span 2;
    grid-row: span 1;
  }

  /* Revert vertical shade strip on narrower viewports — use horizontal layout
     with horizontal scroll if content exceeds viewport. */
  .shades-layout {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .shades-layout::-webkit-scrollbar {
    display: none;
  }

  .bento-shades .nb-shade-strip {
    flex-direction: row;
    min-width: 550px;
  }

  .bento-shades .nb-shade-step {
    flex-direction: column;
    justify-content: center;
    padding: 12px 4px;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    border-bottom: none;
    min-height: 56px;
  }

  .bento-shades .nb-shade-step:last-child {
    border-right: none;
  }

  .bento-shades .nb-shade-step:hover {
    transform: translateY(-2px);
  }

  .picker-layout {
    flex-direction: row;
    gap: var(--nb-space-lg);
  }

  .picker-wheel {
    flex-shrink: 0;
  }

  .picker-inputs {
    border-top: none;
    border-left: var(--nb-border-sm);
    padding-top: 0;
    padding-left: var(--nb-space-lg);
  }
}

/* ---------- Responsive: Mobile ---------- */
@media (max-width: 767px) {
  .bento {
    grid-template-columns: 1fr;
  }

  .bento-picker,
  .bento-adjust,
  .bento-outputs,
  .bento-contrast,
  .bento-harmonies,
  .bento-shades,
  .bento-spin {
    grid-column: span 1;
    grid-row: span 1;
  }

  .page-title {
    font-size: 24px;
  }

  .picker-layout {
    flex-direction: column;
  }

  .picker-inputs {
    border-left: none;
    border-top: var(--nb-border-sm);
    padding-left: 0;
    padding-top: var(--nb-space-md);
  }

  .contrast-ratio {
    font-size: 22px;
  }

  /* On mobile, cards size to natural content height — remove the
     `height: 100%` + `space-evenly` pattern so items aren't pressed
     against the card's bottom border. Default flex-start with
     card padding handles spacing naturally. */
  .picker-layout,
  .contrast-layout {
    height: auto;
    justify-content: flex-start;
  }

  /* Revert to vertical shade strip on mobile — narrow columns can't fit
     11 horizontal steps without off-screen overflow. */
  .shades-layout {
    overflow: visible;
  }

  .bento-shades .nb-shade-strip {
    flex-direction: column;
    min-width: 0;
  }

  .bento-shades .nb-shade-step {
    flex-direction: row;
    justify-content: space-between;
    padding: 10px 14px;
    border-right: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    min-height: 40px;
  }

  .bento-shades .nb-shade-step:last-child {
    border-bottom: none;
  }

  .bento-shades .nb-shade-step:hover {
    transform: translateX(2px);
  }
}
