/*
  Writing Flow - styles
  This file is intentionally plain CSS (no build step).

  NOTE:
  - The project has two class systems:
    - index.html (container/header/btn-primary/card/...)
    - legacy component CSS (app-container/app-header/primary-btn/result-card/...)
  - Prefer editing the compatibility layer selectors that match index.html.
 */

:root {
  --font-sans: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;

  /* Dark Aurora Neon theme */
  --bg-0: #060815;
  --bg-1: #0a0f2a;
  --card: rgba(255, 255, 255, 0.075);
  --card-strong: rgba(255, 255, 255, 0.11);
  --border: rgba(255, 255, 255, 0.16);

  --text: rgba(255, 255, 255, 0.93);
  --text-secondary: rgba(255, 255, 255, 0.72);
  --muted: rgba(255, 255, 255, 0.52);

  --accent: #7c3aed;     /* violet */
  --accent-2: #22d3ee;   /* cyan */
  --accent-3: #a3ff12;   /* neon lime (sparingly) */
  --success: #22c55e;

  --shadow: 0 20px 70px rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.40);
  --glow-accent: 0 0 0 1px rgba(124, 58, 237, 0.22), 0 0 24px rgba(124, 58, 237, 0.28);
  --glow-cyan: 0 0 0 1px rgba(34, 211, 238, 0.18), 0 0 26px rgba(34, 211, 238, 0.20);

  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --focus: 0 0 0 4px rgba(34, 211, 238, 0.24), 0 0 0 1px rgba(34, 211, 238, 0.55);

  /* spacing (8pt-ish) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(900px 620px at 82% 8%, rgba(34, 211, 238, 0.24), transparent 55%),
    radial-gradient(900px 620px at 18% 18%, rgba(124, 58, 237, 0.28), transparent 60%),
    radial-gradient(800px 560px at 62% 58%, rgba(163, 255, 18, 0.12), transparent 62%),
    radial-gradient(600px 520px at 10% 80%, rgba(244, 114, 182, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1));
}

/* ========================================================================== */
/* Compatibility layer (index.html classnames -> existing component styles)     */
/* This repo has no build step; keep it in plain CSS and prefer additive rules */
/* ========================================================================== */

/* App shell */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 18px 40px;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 0 24px;
}

.header-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.82);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

.header-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.main {
  display: grid;
  gap: 18px;
}

/* Inputs */
.input-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(10px);
  position: relative;
}

.input-section::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    135deg,
    rgba(34, 211, 238, 0.22),
    rgba(124, 58, 237, 0.26),
    rgba(163, 255, 18, 0.08)
  );
  opacity: 0.45;
  filter: blur(0.2px);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  -webkit-mask-composite: xor;
  padding: 1px;
}

.input-box {
  display: grid;
  gap: 10px;
}

.textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  padding: 14px 14px;
  font-size: 1rem;
  line-height: 1.6;
  outline: none;
}

.textarea::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.textarea:focus {
  border-color: rgba(99, 102, 241, 0.65);
  box-shadow: var(--focus);
}

.input-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

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

.char-count {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* Controls (provider/model) */
.select-control {
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.select-control:hover {
  border-color: rgba(255, 255, 255, 0.22);
}

.select-control:focus {
  border-color: rgba(99, 102, 241, 0.65);
  box-shadow: var(--focus);
}

/* Style chips + primary CTA */
.style-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.style-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.14);
}

.style-chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.style-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip-content {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--text);
  font-size: 0.88rem;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.style-chip:hover .chip-content {
  background: rgba(255, 255, 255, 0.085);
  border-color: rgba(255, 255, 255, 0.14);
}

.style-chip input:focus-visible + .chip-content {
  box-shadow: var(--focus);
}

.style-chip input:checked + .chip-content {
  border-color: rgba(255, 255, 255, 0.22);
  background:
    radial-gradient(120% 160% at 30% 20%, rgba(255, 255, 255, 0.18), transparent 60%),
    linear-gradient(135deg, rgba(124, 58, 237, 0.50), rgba(34, 211, 238, 0.30));
  box-shadow: var(--glow-accent), 0 0 0 1px rgba(34, 211, 238, 0.22);
  transform: translateY(-1px);
}

/* Extra selection clarity: a small check dot */
.style-chip input:checked + .chip-content::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.20), 0 0 14px rgba(34, 211, 238, 0.28);
}

.chip-icon {
  opacity: 0.95;
}

.btn-primary {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background:
    radial-gradient(120% 120% at 20% 10%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  color: rgba(255, 255, 255, 0.96);
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-soft), var(--glow-accent);
  transform: translateZ(0);
}

.btn-primary > * {
  position: relative;
  z-index: 1;
}

/* Specular sheen (subtle glass highlight) */
.btn-primary::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.22),
    rgba(255, 255, 255, 0.10) 26%,
    rgba(255, 255, 255, 0.00) 62%
  );
  opacity: 0.55;
  mix-blend-mode: screen;
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: inherit;
  pointer-events: none;
  z-index: -1;
  background: radial-gradient(
    70% 90% at 50% 40%,
    rgba(34, 211, 238, 0.26),
    rgba(124, 58, 237, 0.22) 45%,
    transparent 72%
  );
  filter: blur(10px);
  opacity: 0.55;
  transition: opacity 160ms ease, filter 160ms ease;
}

.btn-primary-icon {
  width: 18px;
  height: 18px;
  opacity: 0.95;
}

.btn-primary .btn-text {
  font-size: 0.95rem;
  line-height: 1;
}

.btn-primary:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  filter: saturate(0.8);
  box-shadow: none;
}

.btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.08) saturate(1.08);
}

.btn-primary:not(:disabled):hover::after {
  opacity: 0.80;
  filter: blur(12px);
}

.btn-primary:active {
  transform: translateY(0);
  filter: brightness(0.98) saturate(1.06);
}

.btn-primary:focus {
  outline: none;
}

.btn-primary:focus-visible {
  box-shadow: var(--shadow-soft), var(--glow-accent), var(--focus);
}

/* Results cards */
.results-section {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  backdrop-filter: blur(10px);
  position: relative;
}

.card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    135deg,
    rgba(34, 211, 238, 0.20),
    rgba(124, 58, 237, 0.22),
    rgba(255, 255, 255, 0.06)
  );
  opacity: 0.35;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  -webkit-mask-composite: xor;
  padding: 1px;
}

.card-body {
  padding: 14px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
  cursor: pointer;
}

.btn-icon:hover {
  background: rgba(0, 0, 0, 0.26);
  box-shadow: var(--glow-cyan);
}

.btn-icon:active {
  transform: scale(0.98);
}

.btn-icon:focus {
  outline: none;
}

.btn-icon:focus-visible {
  box-shadow: var(--focus);
}

.btn-icon.copied {
  border-color: rgba(34, 197, 94, 0.55);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

.btn-icon.playing {
  border-color: rgba(99, 102, 241, 0.55);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.18), var(--glow-cyan);
}

.placeholder-text {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.footer kbd {
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.22);
  box-shadow: var(--glow-accent);
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }

  .spinner {
    animation: none;
  }

  .btn-primary,
  .btn-icon {
    transition: none;
  }
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title h3 {
  margin: 0;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.card-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  padding: 6px 0 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.rewrite-text {
  font-size: 1.06rem;
  line-height: 1.72;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.96);
  white-space: pre-wrap;
}

.rewrite-text:empty {
  display: none;
}

.error-message {
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.14);
  color: rgba(255, 255, 255, 0.92);
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

/* Legacy class system cleanup:
   - Intentionally removed in favor of the compatibility layer.
   - Keep shared primitives (card-header/card-title/card-icon/loading-indicator/etc.) above.
*/

/* Additional RWD rules for the current index.html markup */
@media (max-width: 980px) {
  .results-section {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .container {
    padding: 20px 16px 34px;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-right {
    justify-content: stretch;
  }

  .select-control {
    width: 100%;
  }

  .style-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary {
    width: 100%;
  }

  .results-section {
    grid-template-columns: 1fr;
  }
}

/* Mobile: Keep style chips in one row */
@media (max-width: 640px) {
  .style-options {
    flex-wrap: nowrap;
    justify-content: center;
  }
  
  .chip-content {
    padding: 6px 10px;
    font-size: 12px;
    gap: 4px;
  }
  
  .chip-icon {
    width: 12px;
    height: 12px;
  }
}
