/* REFRESH — Matrix vintage 1999 */

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ============================================ */
/* GLITCH INTRO — JS-driven (opacity + clip-path) */
/* ============================================ */
#app {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  opacity: 0; /* écran noir initial — JS prend le relais */
}

:root {
  --green: #00ff41;
  --green-dim: #008f11;
  --green-glow: rgba(0, 255, 65, 0.6);
  --bg: #0d0208;
  --bg-panel: rgba(0, 20, 0, 0.55);
  --border: rgba(0, 255, 65, 0.25);
  --danger: #ff3860;
}

html, body {
  background: var(--bg);
  color: var(--green);
  font-family: 'Courier New', 'Lucida Console', monospace;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

#matrix-rain {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
  /* démarre APRÈS le glitch (2s) puis fade-in très progressif sur 4s */
  animation: rain-fade-in 4s ease-out 2s forwards;
}

@keyframes rain-fade-in {
  0%   { opacity: 0; }
  100% { opacity: 0.45; }
}

/* CRT effect : scanlines + courbure subtile */
.crt {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

.crt::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 3px
  );
}

.crt::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.55) 100%);
}

/* ============================================ */
/* HERO                                          */
/* ============================================ */
.hero {
  text-align: center;
  margin-bottom: 3rem;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}

.logo-orb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--green) 0%, var(--green-dim) 50%, #001a00 100%);
  box-shadow:
    0 0 20px var(--green-glow),
    0 0 40px var(--green-glow),
    inset 0 0 15px rgba(0, 255, 65, 0.3);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 20px var(--green-glow), 0 0 40px var(--green-glow), inset 0 0 15px rgba(0,255,65,0.3); }
  50%      { box-shadow: 0 0 30px var(--green-glow), 0 0 60px var(--green-glow), inset 0 0 20px rgba(0,255,65,0.5); }
}

h1 {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: 0.4rem;
}

.tagline {
  font-size: 0.95rem;
  letter-spacing: 0.1rem;
  opacity: 0.85;
}

.glow {
  text-shadow:
    0 0 8px var(--green-glow),
    0 0 18px var(--green-glow),
    0 0 30px rgba(0, 255, 65, 0.3);
}

.glow-soft {
  text-shadow: 0 0 6px var(--green-glow);
}

/* ============================================ */
/* PANELS                                        */
/* ============================================ */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2rem;
  margin-bottom: 2rem;
  backdrop-filter: blur(2px);
  box-shadow:
    0 0 20px rgba(0, 255, 65, 0.08),
    inset 0 0 30px rgba(0, 255, 65, 0.03);
}

.panel.hidden { display: none; }

.label {
  display: block;
  font-size: 0.85rem;
  letter-spacing: 0.15rem;
  margin-bottom: 0.5rem;
  opacity: 0.8;
}

input[type="url"],
input[type="text"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  color: var(--green);
  font-family: inherit;
  font-size: 1.05rem;
  padding: 0.85rem 1rem;
  border-radius: 2px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

input[type="url"]:focus,
input[type="text"]:focus {
  border-color: var(--green);
  box-shadow: 0 0 10px var(--green-glow);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.2rem 0;
  font-size: 0.9rem;
  cursor: pointer;
  user-select: none;
}

.checkbox input { accent-color: var(--green); width: 16px; height: 16px; }

/* BUTTONS */
.btn-primary,
.btn-ghost {
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green);
  font-family: inherit;
  font-size: 0.95rem;
  letter-spacing: 0.1rem;
  padding: 0.75rem 1.5rem;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.25s ease;
  text-transform: uppercase;
}

.btn-primary {
  background: rgba(0, 255, 65, 0.08);
  font-weight: 700;
  width: 100%;
  margin-top: 1rem;
}

.btn-primary:hover,
.btn-ghost:hover {
  background: var(--green);
  color: var(--bg);
  box-shadow: 0 0 20px var(--green-glow);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.warn {
  margin-top: 1.5rem;
  font-size: 0.82rem;
  opacity: 0.7;
  text-align: center;
  padding: 0.75rem;
  border: 1px dashed var(--border);
}

/* ============================================ */
/* LOADER                                        */
/* ============================================ */
.loader-text {
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 1.5rem;
  letter-spacing: 0.1rem;
}

.loader-text::after {
  content: '_';
  animation: blink 0.8s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.loader-bar {
  height: 4px;
  background: rgba(0, 255, 65, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.loader-bar span {
  display: block;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  animation: scan 1.5s linear infinite;
}

@keyframes scan {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ============================================ */
/* TABS                                          */
/* ============================================ */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--green-dim);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.08rem;
}

.tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
  text-shadow: 0 0 6px var(--green-glow);
}

.tab:hover { color: var(--green); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

#rendered-img,
#source-img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 2px;
  display: block;
}

pre {
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1.2rem;
  max-height: 500px;
  overflow: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

code { color: var(--green); font-family: inherit; }

#copy-code {
  display: block;
  margin-bottom: 0.75rem;
  margin-left: auto;
}

#report-block {
  white-space: pre-wrap;
  font-size: 0.95rem;
  line-height: 1.7;
}

#report-block h2 { font-size: 1.1rem; margin: 1.2rem 0 0.5rem; }

/* ============================================ */
/* REFINE                                        */
/* ============================================ */
.refine-zone {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--border);
}

.refine-zone h3 {
  font-size: 1rem;
  letter-spacing: 0.15rem;
  margin-bottom: 1rem;
}

.refine-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.refine-presets .btn-ghost {
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
}

#refine-input { margin-bottom: 0.75rem; }

/* ============================================ */
/* ERROR                                         */
/* ============================================ */
.error {
  border-color: var(--danger);
  color: var(--danger);
}

#error-msg {
  margin-bottom: 1rem;
  font-size: 1rem;
}

/* ============================================ */
/* RESPONSIVE                                    */
/* ============================================ */
@media (max-width: 640px) {
  h1 { font-size: 2.4rem; letter-spacing: 0.2rem; }
  .logo-orb { width: 40px; height: 40px; }
  .panel { padding: 1.25rem; }
  .crt { padding: 2rem 1rem 4rem; }
}

/* ============================================ */
/* STRIPE CTA — bouton phosphore premium       */
/* ============================================ */
.stripe-cta {
  display: inline-block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  padding: 1rem 1.5rem;
  font-size: 1.05rem;
  letter-spacing: 0.15em;
  border: 2px solid var(--green);
  background: linear-gradient(135deg, rgba(0,255,65,0.08), rgba(0,255,65,0.18));
  color: var(--green);
  text-shadow: 0 0 8px var(--green-glow);
  box-shadow:
    0 0 20px rgba(0,255,65,0.25),
    inset 0 0 20px rgba(0,255,65,0.08);
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
}
.stripe-cta::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 2px,
    rgba(0,255,65,0.04) 2px,
    rgba(0,255,65,0.04) 3px
  );
  pointer-events: none;
}
.stripe-cta:hover {
  background: linear-gradient(135deg, rgba(0,255,65,0.22), rgba(0,255,65,0.42));
  box-shadow:
    0 0 35px rgba(0,255,65,0.55),
    inset 0 0 25px rgba(0,255,65,0.18);
  text-shadow: 0 0 14px var(--green), 0 0 4px #fff;
  animation: stripe-glitch 0.42s steps(2, end) infinite;
}
.stripe-cta:active {
  transform: translateY(1px);
}
@keyframes stripe-glitch {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-1px, 0.5px); }
  50%  { transform: translate(1px, -0.5px); }
  75%  { transform: translate(-0.5px, 1px); }
  100% { transform: translate(0, 0); }
}

/* ============================================ */
/* HOST MODAL — succès + hébergement            */
/* ============================================ */
.host-modal.hidden { display: none !important; }
.host-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  animation: host-fade-in .2s ease-out;
}
@keyframes host-fade-in { from { opacity: 0; } to { opacity: 1; } }

.host-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(4px);
}

.host-modal-content {
  position: relative;
  z-index: 1;
  max-width: 560px;
  width: calc(100% - 2rem);
  max-height: 90vh;
  overflow-y: auto;
  background: #0a0f0a;
  border: 1px solid var(--green);
  box-shadow: 0 0 40px rgba(0,255,65,.25), inset 0 0 40px rgba(0,255,65,.05);
  padding: 1.8rem 1.6rem 1.4rem;
  font-family: 'Courier New','Lucida Console',monospace;
}

.host-modal-close {
  position: absolute; top: .5rem; right: .8rem;
  background: transparent; border: none; color: var(--green);
  font-size: 1.2em; cursor: pointer; opacity: .6;
}
.host-modal-close:hover { opacity: 1; text-shadow: 0 0 8px var(--green-glow); }

.host-block { margin: 1rem 0 1.4rem; }

.host-option {
  border: 1px solid var(--border);
  margin: .6rem 0;
  padding: .7rem .9rem;
  background: rgba(0,255,65,.03);
}
.host-option summary {
  cursor: pointer;
  font-size: .95em;
  letter-spacing: .05em;
  list-style: none;
  display: flex; align-items: center; gap: .6rem;
  flex-wrap: wrap;
}
.host-option summary::-webkit-details-marker { display: none; }
.host-option summary::before {
  content: '▸';
  display: inline-block;
  transition: transform .15s;
  color: var(--green-dim);
}
.host-option[open] summary::before { transform: rotate(90deg); }
.host-option p {
  margin: .8rem 0;
  font-size: .85em;
  line-height: 1.6;
  opacity: .9;
  font-family: -apple-system, sans-serif;
}
.host-option code {
  background: rgba(0,255,65,.1);
  padding: 1px 5px;
  border-radius: 2px;
  font-size: .9em;
}
.host-option .btn-ghost {
  display: inline-block;
  font-size: .8em;
  padding: .4rem .9rem;
  text-decoration: none;
}

.host-badge {
  display: inline-block;
  background: var(--green);
  color: #0a0f0a;
  padding: 2px 8px;
  font-size: .65em;
  letter-spacing: .15em;
  font-weight: bold;
}
.host-badge.alt { background: var(--green-dim); color: #fff; }
.host-badge.alt2 { background: transparent; color: var(--green-dim); border: 1px solid var(--green-dim); }

.host-waitlist {
  border-top: 1px dashed var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}
.host-waitlist input { border-radius: 2px; outline: none; }
.host-waitlist input:focus { border-color: var(--green); box-shadow: 0 0 0 1px var(--green-glow); }

/* ============================================ */
/* PREVIEW — iframe live + plein écran          */
/* ============================================ */
.preview-wrap {
  position: relative;
  width: 100%;
  height: 70vh;
  min-height: 420px;
  background: #0a0f0a;
  border: 1px solid var(--green);
  box-shadow: 0 0 20px rgba(0,255,65,.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .4rem .7rem;
  background: rgba(0,255,65,.05);
  border-bottom: 1px solid rgba(0,255,65,.2);
  font-size: .75em;
  letter-spacing: .2em;
}
.preview-label {
  color: var(--green);
  opacity: .8;
}
.preview-toolbar-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.preview-fullscreen-btn,
.preview-download-btn {
  padding: .35rem .8rem !important;
  font-size: .8em !important;
  letter-spacing: .15em;
}
.preview-download-btn {
  /* CTA principal — vert phosphore plein, plus marqué que ghost pour guider le clic */
  box-shadow: 0 0 12px rgba(0,255,65,.35);
}
.preview-download-btn:hover {
  box-shadow: 0 0 18px rgba(0,255,65,.6);
}
#rendered-iframe {
  width: 100%;
  flex: 1;
  border: 0;
  background: #fff;
}
#rendered-img {
  width: 100%;
  height: auto;
  display: block;
}

/* Modal plein écran */
.preview-modal {
  position: fixed; inset: 0; z-index: 2000;
  background: #000;
  display: flex;
  flex-direction: column;
}
.preview-modal.hidden { display: none !important; }
.preview-modal-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem 1rem;
  background: #0a0f0a;
  border-bottom: 1px solid var(--green);
  color: var(--green);
  font-family: 'Courier New','Lucida Console',monospace;
}
.preview-modal-title {
  font-size: .85em;
  letter-spacing: .25em;
  opacity: .85;
}
.preview-modal-close {
  padding: .35rem .8rem !important;
  font-size: .8em !important;
}
#preview-fullscreen-iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

/* ===========================================================================
   Phase 2 freemium — barre header (tier badge + quota + liens)
   =========================================================================== */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .8rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.tier-zone { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.tier-badge {
  display: inline-block;
  padding: .25rem .65rem;
  font-size: .68em;
  letter-spacing: .25em;
  font-weight: 700;
  border: 1px solid currentColor;
  border-radius: 2px;
  font-family: 'Courier New','Lucida Console',monospace;
}
.tier-badge.tier-free   { color: #ffae42; box-shadow: 0 0 8px rgba(255,174,66,.25); }
.tier-badge.tier-pro    { color: var(--green); box-shadow: 0 0 8px rgba(0,255,65,.3); }
.tier-badge.tier-pending{ color: #888; opacity: .6; }
.quota-info {
  font-size: .78em;
  opacity: .65;
  letter-spacing: .05em;
}
.header-links { display: flex; align-items: center; gap: 1rem; }
.header-link {
  color: var(--green-dim, #4a8a4a);
  font-size: .8em;
  text-decoration: none;
}
.header-link:hover { color: var(--green); }

/* Logout uniquement visible si tier=pro */
html[data-tier="free"] .header-link-logout,
html[data-tier="pending"] .header-link-logout { display: none; }
/* Bouton "j'ai une clé" inutile si déjà pro */
html[data-tier="pro"] #have-key-link { display: none; }
/* En attente vérif clé : on cache les deux pour pas flasher */
html[data-tier="pending"] #have-key-link { display: none; }

/* Refine désactivé en free (preview pro) */
html[data-tier="free"] .refine-btn,
html[data-tier="free"] #refine-btn {
  opacity: .45;
  cursor: not-allowed;
  position: relative;
}
html[data-tier="free"] .refine-btn::after,
html[data-tier="free"] #refine-btn::after {
  content: "🔒";
  margin-left: .4rem;
  font-size: .9em;
}

/* Bouton download free : visuel d'upsell (pas désactivé mais explicite) */
html[data-tier="free"] .preview-download-btn::after {
  content: " 🔒";
  font-size: .85em;
  opacity: .85;
}

/* Zone Turnstile (B7) — visible uniquement pour les free */
.turnstile-zone {
  margin: .8rem 0 1rem;
  min-height: 65px;
  display: flex;
  justify-content: center;
}
.turnstile-zone:empty,
html[data-tier="pro"] .turnstile-zone,
html[data-tier="unrestricted"] .turnstile-zone {
  display: none;
}
.turnstile-zone > div { max-width: 100%; }
