/* pequod-wallpapers
   App chrome uses Pequod itself: Log 50 / Log 950 backgrounds, Log 800 /
   Log 100 text, Log 200 / Log 800 button surfaces, Starbuck for the
   primary action. Buttons stay lowercase.                              */

:root {
  --log-50: #F7F3EE;
  --log-100: #EAE1D7;
  --log-150: #DBC9B6;
  --log-200: #CFAD8E;
  --log-300: #BD8C68;
  --log-400: #A16E50;
  --log-500: #835A49;
  --log-600: #335260;
  --log-700: #163F54;
  --log-800: #0D2F42;
  --log-900: #0C222F;
  --log-950: #0B1720;

  --starbuck-light: #0082B1;
  --starbuck-dark: #A6DFFF;

  --bg: var(--log-50);
  --surface: var(--log-100);
  --surface-2: var(--log-150);
  --text: var(--log-800);
  --text-muted: var(--log-500);
  --border: rgba(22, 63, 84, 0.18);
  --primary: var(--starbuck-light);
  --primary-text: var(--log-100);
  --focus: var(--log-700);

  --font-sans: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius: 4px;
  --dur: 160ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: var(--log-950);
  --surface: var(--log-900);
  --surface-2: var(--log-800);
  --text: var(--log-100);
  --text-muted: var(--log-300);
  --border: rgba(166, 223, 255, 0.18);
  --primary: var(--starbuck-dark);
  --primary-text: var(--log-950);
  --focus: var(--log-300);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute defaults to display:none, but our
   .gallery-drawer and .custom-aspect rules set display:flex/grid,
   which wins over the UA default. Force [hidden] to win back. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.topbar {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  font-family: var(--font-mono);
  text-transform: lowercase;
}

.tagline {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
}

.controls {
  padding: var(--space-5);
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
}

.control {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.control label,
.control legend {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

select,
input[type="text"],
input[type="number"] {
  font: inherit;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
  width: 100%;
}

input[type="text"],
#seed {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.custom-aspect {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-2);
}

.custom-aspect span {
  color: var(--text-muted);
  text-align: center;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center !important;
  gap: var(--space-2) !important;
  text-transform: none !important;
  font-size: 0.95rem !important;
  letter-spacing: 0 !important;
  color: var(--text) !important;
}

.checkbox-row input { width: auto; }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  margin-bottom: var(--space-4);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.88rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.advanced {
  border-top: 1px dashed var(--border);
  padding-top: var(--space-4);
}

.accent-lock {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.accent-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
}

.accent-chip input { width: auto; margin: 0; }

.accent-chip:has(input:checked) {
  background: var(--surface-2);
  border-color: var(--primary);
}

.accent-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .accent-dot {
  border-color: rgba(255, 255, 255, 0.18);
}

.preview {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: var(--surface-2);
  min-height: 0;
  overflow: hidden;
}

.stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg);
  overflow: hidden;
}

.stage svg {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.actions .left,
.actions .right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.actions .right {
  margin-left: auto;
}

button {
  font: inherit;
  font-size: 0.88rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  text-transform: lowercase;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

button:hover { border-color: var(--primary); }

button.primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
  font-weight: 600;
  padding: var(--space-2) var(--space-5);
}

button.primary:hover { filter: brightness(0.95); }

button.icon-btn {
  padding: 2px 6px;
  font-family: var(--font-mono);
  background: transparent;
  border: 1px solid var(--border);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.status {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  min-height: 1.2em;
}

.gallery-drawer {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.gallery-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.gallery-bar h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: lowercase;
}

.gallery-bar .spacer { flex: 1; }

.muted { color: var(--text-muted); font-size: 0.88rem; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.gallery-item {
  margin: 0;
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.gallery-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg);
}

.gallery-item figcaption {
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.gallery-item .icon-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(13, 47, 66, 0.7);
  color: var(--log-100);
  border: 0;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .controls {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 50vh;
  }
  .topbar { padding: var(--space-3) var(--space-4); }
  .topbar h1 { font-size: 0.92rem; }
  .actions { padding: var(--space-2) var(--space-3); }
  .actions .right { margin-left: 0; width: 100%; }
  .preview { padding: var(--space-3); min-height: 40vh; }
}
