/* ═══════════════════════════════════════════════════════════════
   CLOTO RESET — Normalize + Base + WP Compat
   ═══════════════════════════════════════════════════════════════ */

/* ── Box Model Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Body ── */
html, body.cloto-app {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  margin: 0;
}

body.cloto-app {
  background: var(--cloto-void);
  color: var(--cloto-text-100);
  font-family: var(--cloto-font-body);
  font-size: var(--cloto-fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  isolation: isolate;
}

body.cloto-app.fd-light {
  background: var(--cloto-void);
}

/* ── Animated Background — Il Sogno di Cloto ── */

/* Layer 1: Primary nebulae — teal/purple cosmic clouds */
body.cloto-app::before {
  content: '';
  position: fixed;
  inset: -120px;
  z-index: -2;
  pointer-events: none;
  will-change: transform;
  background:
    radial-gradient(ellipse 900px 650px at 8% 35%, var(--cloto-teal-a18) 0%, transparent 70%),
    radial-gradient(ellipse 700px 900px at 92% 15%, rgba(101, 78, 163, 0.15) 0%, transparent 70%),
    radial-gradient(ellipse 550px 450px at 45% 90%, rgba(42, 80, 160, 0.12) 0%, transparent 65%),
    radial-gradient(circle 500px at 70% 55%, rgba(201, 168, 76, 0.07) 0%, transparent 70%),
    radial-gradient(ellipse 400px 300px at 25% 65%, var(--cloto-purple-a8) 0%, transparent 60%);
  animation: cloto-nebula 90s ease-in-out infinite alternate;
}

/* Layer 2: Deep drift — secondary glow + aurora */
body.cloto-app::after {
  content: '';
  position: fixed;
  inset: -120px;
  z-index: -1;
  pointer-events: none;
  will-change: transform;
  background:
    radial-gradient(ellipse 800px 550px at 78% 40%, var(--cloto-teal-a12) 0%, transparent 70%),
    radial-gradient(ellipse 500px 700px at 12% 75%, rgba(167, 139, 250, 0.09) 0%, transparent 65%),
    radial-gradient(circle 450px at 55% 20%, rgba(60, 130, 200, 0.08) 0%, transparent 70%),
    radial-gradient(ellipse 600px 300px at 35% 50%, rgba(94, 198, 198, 0.05) 0%, transparent 60%);
  animation: cloto-nebula-deep 65s ease-in-out infinite alternate-reverse;
}

@keyframes cloto-nebula {
  0%   { transform: translate(0, 0) scale(1);
  opacity: 0.85; }
  20%  { transform: translate(50px, -35px) scale(1.06);
  opacity: 1; }
  40%  { transform: translate(-25px, 20px) scale(0.97);
  opacity: 0.8; }
  60%  { transform: translate(35px, 10px) scale(1.04);
  opacity: 0.95; }
  80%  { transform: translate(-15px, -25px) scale(0.99);
  opacity: 0.88; }
  100% { transform: translate(20px, -10px) scale(1.02);
  opacity: 0.92; }
}

@keyframes cloto-nebula-deep {
  0%   { transform: translate(0, 0) scale(1);
  opacity: 0.75; }
  25%  { transform: translate(-55px, 40px) scale(1.05);
  opacity: 0.9; }
  50%  { transform: translate(40px, -35px) scale(0.95);
  opacity: 0.7; }
  75%  { transform: translate(-30px, 20px) scale(1.03);
  opacity: 0.85; }
  100% { transform: translate(25px, -15px) scale(0.98);
  opacity: 0.78; }
}

/* Light — Le Rovine Dorate — golden desert ruins */
body.cloto-app.fd-light::before {
  background:
    radial-gradient(ellipse 900px 650px at 20% 25%, rgba(201, 168, 76, 0.16) 0%, transparent 70%),
    radial-gradient(ellipse 700px 800px at 85% 55%, rgba(190, 155, 90, 0.13) 0%, transparent 70%),
    radial-gradient(ellipse 500px 400px at 10% 80%, rgba(94, 198, 198, 0.07) 0%, transparent 60%),
    radial-gradient(circle 600px at 55% 10%, rgba(255, 245, 215, 0.25) 0%, transparent 65%),
    radial-gradient(ellipse 400px 350px at 70% 75%, var(--cloto-gold-a8) 0%, transparent 60%);
}

body.cloto-app.fd-light::after {
  background:
    radial-gradient(ellipse 800px 500px at 65% 35%, var(--cloto-gold-a10) 0%, transparent 70%),
    radial-gradient(ellipse 450px 600px at 18% 50%, rgba(180, 150, 100, 0.09) 0%, transparent 65%),
    radial-gradient(circle 550px at 40% 20%, rgba(255, 255, 240, 0.22) 0%, transparent 60%),
    radial-gradient(ellipse 500px 300px at 80% 80%, rgba(210, 180, 120, 0.07) 0%, transparent 60%);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--cloto-teal-a15);
  border-radius: var(--radius-xs);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--cloto-glass-border-active);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--cloto-teal-a15) transparent;
}

/* ── Selection ── */
::selection {
  background: var(--cloto-teal-a25);
  color: var(--cloto-text-100);
}

/* ── Placeholder ── */
::placeholder {
  color: var(--cloto-text-25);
  font-style: italic;
}

/* ── Links ── */
a {
  color: var(--cloto-teal);
  text-decoration: none;
  transition: color var(--duration-normal) var(--ease-spring);
}
a:hover {
  color: var(--cloto-teal-light);
}

/* ── Images ── */
  img, svg { max-width: 100%;
  display: block; }

/* ── Lists ── */
ul, ol { list-style: none; }

/* ══════════════════════════════════════════════════════════════
   WP-COMPATIBLE BUTTON CLASSES
   JS generates `.button`, `.button-primary`, `.button-small`
   ══════════════════════════════════════════════════════════════ */

.button,
button.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-7);
  min-height: 32px;
  font-family: var(--cloto-font-body);
  font-size: var(--cloto-fs-sm);
  font-weight: 500;
  line-height: 1.4;
  color: var(--cloto-text-70);
  background: transparent;
  border: 1px solid var(--cloto-glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
  white-space: nowrap;
  text-decoration: none;
  vertical-align: middle;
}

.button:hover {
  color: var(--cloto-text-100);
  border-color: var(--cloto-glass-border-hover);
  background: var(--cloto-teal-a4);
}

.button:active {
  background: var(--cloto-teal-a8);
}

.button:disabled,
.button[disabled] {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
  pointer-events: none;
}

.button:focus-visible {
  outline: 2px solid var(--cloto-teal-a40);
  outline-offset: 2px;
}

/* Primary */
.button-primary,
.button.button-primary {
  color: var(--cloto-teal);
  background: var(--cloto-teal-a8);
  border-color: var(--cloto-teal-a25);
}
.button-primary:hover {
  background: var(--cloto-teal-a15);
  border-color: var(--cloto-teal-a40);
  color: var(--cloto-teal-light);
}

/* Small */
.button-small,
.button.button-small {
  padding: var(--space-2) var(--space-5);
  min-height: 26px;
  font-size: var(--cloto-fs-xs);
}

/* ══════════════════════════════════════════════════════════════
   FORM ELEMENTS — Glass Dark Styling
   ══════════════════════════════════════════════════════════════ */

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: var(--space-4) var(--space-6);
  font-family: var(--cloto-font-body);
  font-size: var(--cloto-fs-base);
  color: var(--cloto-text-100);
  background: var(--cloto-void-a60);
  border: 1px solid var(--cloto-teal-a12);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--duration-normal) var(--ease-default), box-shadow var(--duration-normal) var(--ease-default);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--cloto-teal-a35);
  box-shadow: var(--shadow-focus-teal);
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235ec6c6' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: var(--space-16);
  cursor: pointer;
}

label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--cloto-fs-xs);
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--cloto-text-40);
}

/* ══════════════════════════════════════════════════════════════
   UTILITY — Markdown, Status, Loading
   ══════════════════════════════════════════════════════════════ */

#fbw-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.fbw-wrap {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.fbw-main {
  flex: 1 1 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* #fbw-outline-root display now controlled by .is-active in cloto-nav.css */

.fbw-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  font-size: var(--cloto-fs-lg);
  color: var(--cloto-text-40);
}

.fbw-error {
  padding: var(--space-8);
  color: var(--cloto-danger);
  text-align: center;
}

.fbw-empty {
  padding: var(--space-16);
  text-align: center;
  color: var(--cloto-text-40);
  font-style: italic;
}

.fbw-status {
  font-size: var(--cloto-fs-xs);
  color: var(--cloto-text-40);
}

.muted {
  color: var(--cloto-text-40);
}

/* Markdown rendered content */
.fbw-md {
  line-height: 1.7;
  color: var(--cloto-text-70);
}
.fbw-md p + p { margin-top: 0.8em; }
  .fbw-md strong { color: var(--cloto-text-100);
  font-weight: 600; }
.fbw-md em { font-style: italic; }
  .fbw-md ul, .fbw-md ol { padding-left: 1.5em;
  margin: 0.5em 0; }
.fbw-md li { margin: 0.25em 0; }
.fbw-md li::marker { color: var(--cloto-teal); }
.fbw-md code {
  font-family: var(--cloto-font-mono);
  font-size: 0.9em;
  padding: var(--space-1) var(--space-3);
  background: var(--cloto-teal-a6);
  border-radius: var(--radius-xs);
  color: var(--cloto-teal);
}
.fbw-md blockquote {
  border-left: 3px solid var(--cloto-teal-a20);
  padding-left: var(--space-6);
  color: var(--cloto-text-40);
  font-style: italic;
  margin: 0.5em 0;
}
.fbw-md h1, .fbw-md h2, .fbw-md h3 {
  color: var(--cloto-text-100);
  margin: 1em 0 0.5em;
}

/* ══════════════════════════════════════════════════════════════
   LIGHT THEME — Reset Overrides
   ══════════════════════════════════════════════════════════════ */

body.fd-light input[type="text"],
body.fd-light input[type="number"],
body.fd-light input[type="email"],
body.fd-light input[type="password"],
body.fd-light input[type="search"],
body.fd-light input[type="url"],
body.fd-light select,
body.fd-light textarea {
  background-color: rgba(255, 255, 255, 0.6);
  border-color: rgba(26, 28, 40, 0.12);
  color: var(--cloto-text-100);
}

body.fd-light input::placeholder,
body.fd-light textarea::placeholder {
  color: rgba(26, 28, 40, 0.35);
}

body.fd-light label {
  color: #6a6a76;
}

body.fd-light .button,
body.fd-light button.button {
  color: #3a3c48;
  border-color: var(--cloto-surface-a10);
}

body.fd-light .button:hover {
  color: var(--cloto-text-100);
  background: var(--cloto-teal-a6);
  border-color: var(--cloto-teal-a20);
}

body.fd-light .button-primary,
body.fd-light .button.button-primary {
  color: var(--cloto-teal);
  border-color: var(--cloto-teal-a30);
}

body.fd-light .fbw-loading {
  color: #6a6a76;
}
