/* ============================================================
   TextScope – style.css
   Sections:
   1.  Tokens (CSS variables) — mirrors QRaft exactly
   2.  Reset & Base
   3.  Background Orbs
   4.  Header
   5.  Main Layout
   6.  Hero
   7.  Grid & Cards
   8.  Textarea (Input card)
   9.  Highlight Box
   10. Stats Grid
   11. Top Words
   12. Action Buttons
   13. Divider
   14. Ad Slots
   15. Toast
   16. Animations & Keyframes
   17. Responsive
   ============================================================ */


/* ── 1. Tokens ── */
:root {
  --red:        #e34949;
  --red-dim:    #c93c3c;
  --red-glow:   rgba(227, 73, 73, 0.25);

  /* Light theme */
  --bg:           #f5f5f7;
  --surface:      #ffffff;
  --surface-2:    #fafafa;
  --border:       rgba(0, 0, 0, 0.08);
  --text:         #1d1d1f;
  --text-2:       #6e6e73;
  --text-3:       #aeaeb2;
  --shadow-sm:    0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md:    0 8px 32px rgba(0, 0, 0, 0.10);
  --shadow-lg:    0 24px 64px rgba(0, 0, 0, 0.12);
  --glass:        rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] {
  --bg:           #000000;
  --surface:      #1c1c1e;
  --surface-2:    #2c2c2e;
  --border:       rgba(255, 255, 255, 0.08);
  --text:         #f5f5f7;
  --text-2:       #aeaeb2;
  --text-3:       #636366;
  --shadow-sm:    0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md:    0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-lg:    0 24px 64px rgba(0, 0, 0, 0.6);
  --glass:        rgba(28, 28, 30, 0.8);
  --glass-border: rgba(255, 255, 255, 0.08);
}


/* ── 2. Reset & Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.35s ease, color 0.35s ease;
}


/* ── 3. Background Orbs ── */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: orb-drift 18s ease-in-out infinite alternate;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: var(--red);
  top: -120px;
  right: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 350px;
  height: 350px;
  background: #1d1d1f;
  bottom: 100px;
  left: -80px;
  animation-delay: -6s;
}

[data-theme="dark"] .orb-2 {
  background: #555;
}


/* ── 4. Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 60px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: var(--glass);
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.35s ease, border-color 0.35s ease;
}

/* Logo wrap */
.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fade-down 0.5s ease both;
}

/* Red rounded square housing the logo image */
.logo-icon {
  width: 34px;
  height: 34px;
  background: var(--red);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px var(--red-glow);
  overflow: hidden;
  transition: transform 0.2s ease;
  cursor: pointer;
  flex-shrink: 0;
}

.logo-icon:hover {
  transform: rotate(-6deg) scale(1.08);
}

.logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.logo-name {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* "Scope" part in red — mirrors QRaft's Q<span>R</span>aft */
.logo-name span {
  color: var(--red);
}

/* Theme toggle — identical to QRaft */
.theme-toggle {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease;
  animation: fade-down 0.5s 0.1s ease both;
}

/* Sliding pill */
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease;
}

[data-theme="dark"] .theme-toggle::after {
  transform: translateX(18px);
  background: var(--red);
}

/* Sun / moon icons sit behind the pill */
.toggle-icons {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
  pointer-events: none;
  font-size: 9px;
  color: var(--text-3);
}


/* ── 5. Main Layout ── */
main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px 32px;
}


/* ── 6. Hero ── */
.hero {
  text-align: center;
  margin-bottom: 40px;
  animation: fade-up 0.6s ease both;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--text);
}

.hero h1 em {
  font-style: normal;
  color: var(--red);
}

.hero p {
  margin-top: 12px;
  font-size: 0.95rem;
  color: var(--text-2);
}


/* ── 7. Grid & Cards ── */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  animation: fade-up 0.6s 0.1s ease both;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow-sm);
  transition: background 0.35s ease, border-color 0.35s ease, box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 14px;
}


/* ── 8. Textarea ── */
textarea {
  width: 100%;
  min-height: 240px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.6;
}

textarea::placeholder {
  color: var(--text-3);
}


/* ── 9. Highlight Box ── */
#highlightBox {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.6;
  color: var(--text);
  min-height: 40px;
  max-height: 180px;
  overflow-y: auto;
  transition: background 0.35s ease, border-color 0.35s ease;
}

/* Token highlight colours — red accent matches QRaft brand */
.word   { color: var(--text); }
.number { color: #4f8cff; }
.symbol { color: var(--red); }
.space  { opacity: 0.3; }


/* ── 10. Stats Grid ── */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-2);
  transition: background 0.35s ease, border-color 0.35s ease;
}

.stat b {
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
}

/* Reading time spans full width */
.reading-stat {
  grid-column: 1 / -1;
}


/* ── 11. Top Words ── */
#topWords {
  list-style: none;
  margin-top: 4px;
}

#topWords li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}

#topWords li:last-child {
  border-bottom: none;
}

#topWords li span {
  color: var(--text);
  font-weight: 500;
}

#topWords li b {
  background: var(--red);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  min-width: 28px;
  text-align: center;
}


/* ── 12. Action Buttons ── */
.btn-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, color 0.2s ease;
}

.btn-action:hover {
  border-color: var(--red);
  color: var(--red);
  transform: translateY(-1px);
}

.btn-action:active {
  transform: translateY(0);
}

.btn-action.primary {
  background: var(--red);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px var(--red-glow);
}

.btn-action.primary:hover {
  background: var(--red-dim);
  color: #fff;
  transform: translateY(-1px);
}


/* ── 13. Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}


/* ── 14. Ad Slots ── */
.ads-row {
  margin-top: 28px;
  display: flex;
  gap: 16px;
  animation: fade-up 0.6s 0.2s ease both;
}

.ad-slot {
  flex: 1;
  height: 90px;
  border-radius: 14px;
  border: 1.5px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
  background: var(--surface);
}


/* ── 15. Toast ── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 22px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  z-index: 999;
  white-space: nowrap;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}


/* ── 16. Animations & Keyframes ── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0);    }
}

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0);     }
}

@keyframes orb-drift {
  from { transform: translate(0, 0)       scale(1);   }
  to   { transform: translate(30px, 40px) scale(1.1); }
}


/* ── 17. Responsive ── */
@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  main {
    padding: 32px 18px 24px;
  }

  .hero h1 {
    font-size: 2.2rem;
  }

  .card {
    padding: 20px;
  }
}

@media (max-width: 600px) {
  header {
    height: 56px;
    padding: 0 14px;
  }

  .logo-name {
    font-size: 1rem;
  }

  .logo-icon {
    width: 30px;
    height: 30px;
  }

  main {
    padding: 24px 14px 20px;
  }

  .hero {
    margin-bottom: 28px;
  }

  .hero h1 {
    font-size: 1.8rem;
    line-height: 1.2;
  }

  .hero p {
    font-size: 0.85rem;
  }

  .card {
    padding: 16px;
    border-radius: 16px;
  }

  textarea {
    min-height: 180px;
    font-size: 0.9rem;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .reading-stat {
    grid-column: auto;
  }

  .stat {
    padding: 10px 12px;
    font-size: 0.8rem;
  }

  #topWords li {
    font-size: 0.78rem;
  }

  #highlightBox {
    font-size: 0.8rem;
    padding: 10px;
  }

  .btn-action {
    padding: 10px;
    font-size: 0.82rem;
  }

  .ads-row {
    flex-direction: column;
  }

  .ad-slot {
    height: 60px;
  }
}

@media (max-width: 400px) {
  .hero h1 {
    font-size: 1.6rem;
  }

  .logo-name {
    font-size: 0.95rem;
  }

  .stat {
    font-size: 0.75rem;
  }
}