/* Modern Artistic Color Classifier */

/* Prevent horizontal layout jump when dynamic content changes trigger scrollbar changes */
html {
  scrollbar-gutter: stable;
}

/* Keep the page content at a comfortable desktop width */
.container {
  max-width: 725px;
}

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  transition: transform 0.3s ease-in-out;
  /* Remove extra inset so the Home link aligns with the card contents */
  padding: 0;
}

.header.header-hidden {
  transform: translateY(-100%);
}

/* <=768px: remove header/card styling concerns on this page (disable sticky + hide transform) */
@media (max-width: 768px) {
  .header {
    position: static;
    top: auto;
    transition: none;
  }

  .header.header-hidden {
    transform: none;
  }

  .header .header-content,
  .header .nav,
  .header .app-header {
    all: revert;
  }
}

.header .header-content {
  /* Make Home sit to the left of the title for this tool */
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "nav title";
  align-items: center;
  column-gap: 0.75rem;
  width: 100%;
  padding: 1rem;
}

.header .nav {
  grid-area: nav;
  justify-self: start;
}

.header .app-header {
  grid-area: title;
  justify-self: center;
  text-align: center;
}

.cc-page {
  display: grid;
  justify-items: center;
  align-items: start;
  width: 100%;
}

.color-classifier-card {
  /* lock width so content swaps can't shrink/expand the card */
  width: 100%;
  max-width: 725px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-rows: auto auto 1fr;
  --cc-panel-max: 360px;
}

.app-header {
  text-align: center;
  margin: 0;
}

.app-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--color-text-light);
  font-size: 1rem;
  font-weight: 400;
}

.color-picker-container {
  margin-top: 0.75rem;
}

.picker-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "preview inputs"
    "hue sb";
  gap: 0.9rem;
  align-items: start;
  justify-items: stretch;
}

.cc-panel {
  display: grid;
  place-items: stretch;
}

.cc-hue { grid-area: hue; }
.cc-preview {
  grid-area: preview;
  place-items: stretch;
}
.cc-sb { grid-area: sb; }
.cc-inputs-panel { grid-area: inputs; }

/* Panels become fluid; we use aspect-ratio instead of fixed px sizes */
.hue-wheel-container,
.sb-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: var(--cc-panel-max);
}

.color-preview-large {
  width: 100%;
  height: 100%;
  min-height: 200px;
  max-width: 100%;
}

/* Page-specific sizing/centering for the output preview container */
#colorPreview {
  max-width: 300px;
  justify-self: start;
}

/* Make hue wheel and saturation/brightness square smaller to prevent pixelation on large screens */
.hue-wheel-container,
.sb-container {
  max-width: min(280px, var(--cc-panel-max));
}

.cc-hue,
.cc-sb {
  place-items: center;
}

/* Keep the hue wheel aligned with the preview (left edge) */
.cc-hue {
  place-items: start;
}

.hue-wheel-container {
  justify-self: start;
}

/* Align the saturation/brightness square and inputs to the right edge */
.cc-sb {
  place-items: end;
}

.sb-container {
  justify-self: end;
}

.cc-inputs-panel {
  justify-items: end;
}

.cc-inputs {
  max-width: min(280px, var(--cc-panel-max));
  justify-self: end;
}

.cc-inputs input.hex-input {
  max-width: none;
}

.cc-preview {
  place-items: stretch;
  display: grid;
}

.cc-inputs-panel {
  display: grid;
  place-items: stretch;
}

/* Hue Wheel */
.hue-wheel-container {
  position: relative;
  cursor: pointer;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

.hue-wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  outline: none;
}

.hue-indicator {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid white;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 0 2px rgba(0, 0, 0, 0.1);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.1s ease, top 0.1s ease;
}

/* Saturation/Brightness Area */
.sb-container {
  position: relative;
  cursor: crosshair;
  border-radius: 12px;
  overflow: hidden;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.sb-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 10px;
  outline: none;
}

.hue-wheel:focus,
.sb-canvas:focus {
  outline: none;
}

.sb-indicator {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 3px solid white;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 0 2px rgba(0, 0, 0, 0.2);
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.1s ease, top 0.1s ease;
}

.color-preview-large {
  /* lock preview size independent of content */
  --preview-fg: #fff;
  border-radius: 20px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.15));
  border: 3px solid rgba(255, 255, 255, 0.1);
  transition: background-color 0.2s ease;
}

.color-preview-large::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);
  pointer-events: none;
}

.color-preview-inner {
  text-align: center;
  z-index: 1;
  padding: 0.75rem;
  display: grid;
  gap: 0.45rem;
  color: var(--preview-fg);
}

.color-preview-large.preview-light { --preview-fg: #000; }
.color-preview-large.preview-dark { --preview-fg: #fff; }

.color-hex,
.color-rgb {
  color: var(--preview-fg);
}

.color-hex {
  font-size: clamp(1.25rem, 2.5vw, 1.85rem);
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.05em;
  margin-bottom: 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.color-rgb {
  font-size: 1rem;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  opacity: 0.9;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.rgb-input-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  place-items: stretch;
  width: 100%;
  margin-top: 0;
}

.cc-inputs {
  display: grid;
  gap: 0.75rem;
  place-items: stretch;
  width: 100%;
  height: 100%;
  align-content: center;
}

.input-group {
  display: grid;
  gap: 0.4rem;
}

.input-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  opacity: 0.8;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hex-input-row {
  display: grid;
  place-items: stretch;
}

/* Use input.class specificity to beat shared-modern.css input[type="text"] background rule */
input.rgb-input {
  width: 100%;
  height: 28px;
  padding: 0 0.35rem;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.20),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  color: var(--color-text);
  font-weight: 700;
  letter-spacing: 0.02em;
  outline: none;
  text-align: center;
}

.rgb-input::placeholder {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 700;
}

input.rgb-input:focus {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.10);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 0 3px rgba(255, 255, 255, 0.10);
}

input.hex-input {
  width: 100%;
  max-width: 18ch;
  height: 28px;
  padding: 0 0.6rem;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.20),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  color: var(--color-text);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  outline: none;
  text-align: center;
}

.hex-input::placeholder {
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.03em;
  text-transform: none;
}

input.hex-input:focus {
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.10);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 0 3px rgba(255, 255, 255, 0.10);
}

/* Override browser autofill colors to preserve vibe */
input.hex-input:-webkit-autofill,
input.hex-input:-webkit-autofill:hover,
input.hex-input:-webkit-autofill:focus,
input.rgb-input:-webkit-autofill,
input.rgb-input:-webkit-autofill:hover,
input.rgb-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--color-text);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.20),
    inset 0 0 0 999px rgba(255, 255, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.16) !important;
  caret-color: var(--color-text);
}

/* Inline predictions inside the preview (no table/card) */
.prediction-inline {
  width: min(28ch, 100%);
  justify-self: center;
  display: grid;
  gap: 0.25rem;
  color: var(--preview-fg);
}

.color-preview-large.preview-light .prediction-inline {
  border: none;
  outline: none;
}

.pred-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.1rem 0;
}

.pred-label {
  text-align: left;
  font-weight: 650;
  font-size: 0.9rem;
  text-transform: capitalize;
  letter-spacing: 0.01em;
  color: var(--preview-fg);
}

.pred-confidence {
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 650;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.95;
  color: var(--preview-fg);
}

.pred-placeholder {
  font-style: italic;
  font-size: 0.9rem;
  opacity: 0.9;
  color: var(--preview-fg);
}

.pred-error {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--preview-fg);
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Responsive Design */
@media (max-width: 200px) {
  .picker-wrapper {
    grid-template-columns: 1fr;
    grid-template-areas:
      "preview"
      "inputs"
      "hue"
      "sb";
  }
}

@media (max-width: 520px) {
  .color-classifier-card {
    padding: 0.75rem;
    --cc-panel-max: 360px;
  }
  
  /* On small screens, keep preview and inputs side by side but adjust proportions */
  .picker-wrapper {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }
  
  .color-preview-large {
    min-height: 150px;
  }
}

/* Tablet / desktop: maintain 2-column layout for preview and inputs */
@media (min-width: 860px) {
  .color-classifier-card { --cc-panel-max: 440px; }
  .picker-wrapper {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "preview inputs"
      "hue sb";
    gap: 1.1rem;
  }
  
  .color-preview-large {
    min-height: 250px;
  }
}

/* Header tweaks for small screens: center title, put nav below */
@media (max-width: 640px) {
  .header .header-content {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "nav";
    justify-items: center;
    row-gap: 0.25rem;
  }

  .header .nav {
    justify-self: center;
  }
}

/* Status Message Styles */
.status-message {
  text-align: center;
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.status-message.info {
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.3);
  color: var(--color-text);
}

.status-message.success {
  background: rgba(76, 175, 80, 0.1);
  border: 1px solid rgba(76, 175, 80, 0.3);
  color: var(--color-text);
}

.status-message.warning {
  background: rgba(255, 152, 0, 0.1);
  border: 1px solid rgba(255, 152, 0, 0.3);
  color: var(--color-text);
}