/* =============================================
   RESET & VARIABLES
============================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:             #f5f4f0;
  --surface:        #ffffff;
  --border:         #e2e0da;
  --border2:        #d0cdc5;

  --text:           #1a1916;
  --text-sub:       #6b6860;
  --text-muted:     #9e9b95;

  --green:          #2a7a4b;
  --green-bg:       #eaf7ee;
  --green-border:   #b8e8c8;

  --blue:           #1a5fa8;
  --blue-bg:        #eaf2fc;
  --blue-border:    #b3d4f5;

  --coral:          #c44b2a;
  --coral-bg:       #fdf0ec;
  --coral-border:   #f5c4b4;

  --accent:         #2a7a4b;
  --radius:         10px;
  --shadow:         0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);

  /* Ad column width — change to 300px if using 300×600 half-page ad */
  --ad-sidebar-w:   180px;
  --stats-w:        300px;
  --page-max:       1200px;
  --page-pad:       28px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* =============================================
   HEADER
============================================= */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--page-pad);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  animation: fadeUp 0.4s ease both;
}

.logo {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.logo span { color: var(--accent); }

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-sub);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 20px;
}

/* =============================================
   HERO
============================================= */
.hero {
  padding: 30px var(--page-pad) 18px;
  max-width: var(--page-max);
  margin: 0 auto;
  animation: fadeUp 0.5s ease 0.05s both;
}

.hero h1 {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

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

.hero p {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--text-sub);
  max-width: 480px;
  line-height: 1.65;
}

/* =============================================
   WORKSPACE — 3-column grid
   [editor flex] [stats 300px] [sidebar-ad 180px]
============================================= */
.workspace {
  display: grid;
  grid-template-columns: 1fr var(--stats-w) var(--ad-sidebar-w);
  gap: 18px;
  padding: 18px var(--page-pad) 32px;
  max-width: var(--page-max);
  margin: 0 auto;
  align-items: start;
  animation: fadeUp 0.5s ease 0.1s both;
}

/* =============================================
   PANEL LABELS
============================================= */
.panel-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* =============================================
   EDITOR PANEL (COL 1)
============================================= */
.editor-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.textarea-wrap { position: relative; }

textarea {
  width: 100%;
  height: 420px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.9rem;
  line-height: 1.7;
  padding: 16px 18px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
}

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

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42,122,75,0.1);
}

.clear-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-sub);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0;
  pointer-events: none;
}

.clear-btn.visible { opacity: 1; pointer-events: auto; }
.clear-btn:hover   { background: #fff0ee; border-color: var(--coral-border); color: var(--coral); }

/* TICKER */
.ticker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 10px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.ticker span { color: var(--accent); font-weight: 700; }

/* =============================================
   STATS PANEL (COL 2)
============================================= */
.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 0;
}

/* 3 mini stat cards */
.cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
}

.stat-card:hover { transform: translateY(-2px); }
.stat-card.green { background: var(--green-bg); border-color: var(--green-border); }
.stat-card.blue  { background: var(--blue-bg);  border-color: var(--blue-border);  }
.stat-card.coral { background: var(--coral-bg); border-color: var(--coral-border); }

.stat-card .card-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.stat-card .card-value {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-card.green .card-value { color: var(--green); }
.stat-card.blue  .card-value { color: var(--blue);  }
.stat-card.coral .card-value { color: var(--coral); }

/* Readability */
.meter-card,
.tone-card,
.words-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.meter-card .card-label,
.tone-card  .card-label,
.words-card .card-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.meter-track {
  height: 6px;
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.meter-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, #e05050, #f0a840, #2a7a4b);
  width: 0%;
  transition: width 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.readability-score-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 8px;
  min-height: 1.3em;
}

/* Tone */
.tone-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tone-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  color: var(--text-sub);
  background: var(--bg);
  transition: all 0.2s;
}

.tone-tag.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Top words */
.word-list    { display: flex; flex-direction: column; gap: 7px; }

.empty-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  padding: 14px 0;
  line-height: 1.6;
}

.word-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}

.word-name {
  width: 76px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.76rem;
}

.word-bar-track {
  flex: 1;
  height: 4px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.word-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.word-count {
  font-size: 0.66rem;
  color: var(--text-muted);
  font-weight: 600;
  width: 16px;
  text-align: right;
}

/* Copy button */
.copy-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  width: 100%;
  transition: background 0.2s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(42,122,75,0.22);
}

.copy-btn:hover  { background: #236640; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(42,122,75,0.28); }
.copy-btn:active { transform: translateY(0); }

/* =============================================
   SIDEBAR AD (COL 3)
   160×600 Wide Skyscraper — sticky so it stays
   visible as user scrolls through the stats
============================================= */
.ad-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: sticky;
  top: 70px;           /* clears the sticky header */
}

/* =============================================
   MOBILE AD SLOT
   Hidden on desktop, shown between editor & stats
   on mobile only
============================================= */
.ad-mobile {
  display: none;        /* hidden by default (desktop) */
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
}

/* =============================================
   BOTTOM BANNER AD
   728×90 leaderboard on desktop / responsive on mobile
============================================= */
.ad-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px var(--page-pad) 8px;
  max-width: var(--page-max);
  margin: 0 auto;
}

.ad-leaderboard {
  width: 100%;
  max-width: 728px;
  height: 90px;
}

/* =============================================
   AD SHARED STYLES
   Ad slots are completely invisible until a real
   ad network tag is placed inside them.
   The .ad-label and .ad-placeholder are hidden —
   delete the placeholder <div> when adding real ads.
============================================= */

/* Hide the "Advertisement" label — only show when
   a real ad is present (ad networks add content) */
.ad-label {
  display: none;
}

/* Hide the dev placeholder box entirely */
.ad-placeholder {
  display: none;
}

/* Hide the entire slot wrapper when empty so it
   takes up zero space and leaves no gap */
.ad-sidebar,
.ad-bottom,
.ad-mobile {
  min-height: 0;
}

.ad-sidebar:empty,
.ad-bottom:empty {
  display: none;
}

/*
  ── HOW TO ACTIVATE ADS ──────────────────────────
  1. Delete the <div class="ad-placeholder"> element
     from index.html for that slot.
  2. Paste your real ad tag (<ins ...> or equivalent)
     directly inside the slot wrapper.
  3. Remove display:none from .ad-label above so
     the "Advertisement" label reappears correctly.
  ─────────────────────────────────────────────────
*/

/* =============================================
   FOOTER
============================================= */
footer {
  border-top: 1px solid var(--border);
  padding: 14px var(--page-pad);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  max-width: var(--page-max);
  margin: 0 auto;
}

.footer-left  { font-weight: 500; }
.footer-left strong { color: var(--text); font-weight: 700; }

.footer-right { display: flex; gap: 12px; align-items: center; }

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.footer-link:hover { color: var(--accent); }

/* =============================================
   ANIMATIONS
============================================= */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.pop { animation: pop 0.25s ease; }

/* =============================================
   RESPONSIVE — TABLET (≤1060px)
   Drop sidebar ad, keep 2-column layout
============================================= */
@media (max-width: 1060px) {
  :root {
    --ad-sidebar-w: 0px;
  }

  .workspace {
    grid-template-columns: 1fr var(--stats-w);
  }

  .ad-sidebar { display: none; }
}

/* =============================================
   RESPONSIVE — MOBILE (≤860px)
   Stack everything, show mobile ad slot
============================================= */
@media (max-width: 860px) {
  :root { --page-pad: 16px; }

  .workspace {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Mobile ad appears between editor & stats */
  .ad-mobile { display: flex; }

  .stats-panel { margin-top: 20px; }

  textarea { height: 260px; }

  .hero { padding: 22px var(--page-pad) 14px; }

  header { padding: 14px var(--page-pad); }

  .ad-leaderboard { height: 50px; }

  footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    padding: 14px var(--page-pad);
  }

  .footer-right { flex-wrap: wrap; justify-content: center; gap: 8px; }
}

/* =============================================
   RESPONSIVE — SMALL MOBILE (≤420px)
============================================= */
@media (max-width: 420px) {
  .hero h1  { font-size: 1.35rem; }
  .cards-row { gap: 6px; }
  .stat-card { padding: 10px 8px; }
  .stat-card .card-value { font-size: 1.2rem; }
  .ticker { font-size: 0.72rem; gap: 4px 12px; }

  /* On very small screens show a 320×50 instead of 320×100 */
  .ad-mobile .ad-placeholder { height: 50px !important; }
}