/* ============================================================
   typing-tool.css — AlphaTyping.com
   Light Theme | Responsive | All Typing Pages
   ============================================================ */

:root {
  --bg      : #f0f2f8;
  --surface : #ffffff;
  --border  : #e2e6ef;
  --text    : #1a1d2e;
  --muted   : #6b7280;
  --muted2  : #9ca3af;

  --blue       : #2563eb;
  --blue-light : #dbeafe;
  --blue-dark  : #1d4ed8;
  --green      : #16a34a;
  --green-light: #dcfce7;
  --red        : #dc2626;
  --red-light  : #fee2e2;

  /* Finger zone pastel colors */
  --f-lp : #ede9fe;
  --f-lr : #dbeafe;
  --f-lm : #ccfbf1;
  --f-li : #dcfce7;
  --f-ri : #fef9c3;
  --f-rm : #ffedd5;
  --f-rr : #fee2e2;
  --f-rp : #fce7f3;

  --radius-lg : 20px;
  --radius-md : 14px;
  --radius-sm : 8px;
  --shadow    : 0 4px 24px rgba(0,0,0,.09);
  --shadow-sm : 0 2px 10px rgba(0,0,0,.07);
  --font      : 'Outfit', ui-sans-serif, system-ui, sans-serif;
  --mono      : ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.atp-wrap {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 3rem;
}
.atp-wrap a { color: inherit; text-decoration: none; }

/* ── Hero ── */
.atp-hero {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 60%, #0ea5e9 100%);
  color: #fff;
  padding: 2.1rem 1rem 1.8rem;
  text-align: center;
}
.atp-hero h1 {
  font-size: clamp(1.4rem, 3vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -.03em;
  margin-bottom: .4rem;
}
.atp-hero p {
  font-size: .95rem;
  color: rgba(255,255,255,.88);
  max-width: 58ch;
  margin: 0 auto;
  line-height: 1.6;
}
.atp-breadcrumb {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  margin-bottom: .75rem;
  font-size: .82rem;
  color: rgba(255,255,255,.75);
}
.atp-breadcrumb a { color: rgba(255,255,255,.9); }
.atp-breadcrumb a:hover { color: #fff; text-decoration: underline; }
.atp-breadcrumb span { opacity: .55; }

/* ── Frame ── */
.atp-frame { padding: 1.25rem 1rem 2.5rem; }

/* ── Card ── */
.atp-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  max-width: 1080px;
  margin: 0 auto;
}

/* ── Top Bar ── */
.atp-topbar {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #fafbff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.atp-title strong { display: block; font-size: 1rem; font-weight: 800; }
.atp-title span   { font-size: .82rem; color: var(--muted); }

/* ── Tabs ── */
.atp-tabs { display: flex; flex-wrap: wrap; gap: .3rem; }
.atp-tab {
  padding: .38rem .7rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: .82rem;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all .15s;
  white-space: nowrap;
}
.atp-tab:hover    { background: #f0f4ff; color: var(--blue); border-color: var(--blue); }
.atp-tab.is-active{ background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Stats ── */
.atp-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
}
.atp-stat {
  padding: .85rem .75rem;
  text-align: center;
  border-right: 1px solid var(--border);
}
.atp-stat:last-child { border-right: none; }
.atp-stat label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .2rem;
}
.atp-stat strong {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
}

/* ── Controls ── */
.atp-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #fafbff;
}
.atp-btnRow { display: flex; gap: .45rem; }

.atp-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .58rem 1.15rem;
  border-radius: 999px;
  font-family: var(--font);
  font-weight: 700;
  font-size: .875rem;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.atp-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.atp-btn--primary {
  background: linear-gradient(135deg, var(--blue), #0ea5e9);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 3px 12px rgba(37,99,235,.28);
}
.atp-btn--primary:hover { box-shadow: 0 5px 18px rgba(37,99,235,.38); }

.atp-toggle {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.atp-toggle input { accent-color: var(--blue); }

/* ── Tip bar ── */
.atp-instructions {
  padding: .58rem 1.25rem;
  font-size: .838rem;
  color: #92400e;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  line-height: 1.5;
}

/* ── Typing Card ── */
.atp-typingCard { padding: 1.4rem 1.25rem 1rem; }

/* ── Words display ── */
.atp-words {
  font-family: var(--mono);
  font-size: clamp(1rem, 2.2vw, 1.45rem);
  line-height: 2.6;
  letter-spacing: .06em;
  word-spacing: .75em;
  color: var(--muted2);
  min-height: 110px;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  background: #f8faff;
  border: 1.5px solid #e0e7ff;
  overflow-wrap: break-word;
  word-break: break-all;
  position: relative;
}

/* ── Characters ── */
.atp-ch { display: inline; border-radius: 3px; }

.atp-ch.is-current {
  color: var(--blue-dark);
  background: var(--blue-light);
  outline: 2px solid var(--blue);
  outline-offset: 1px;
  border-radius: 4px;
}
.atp-ch.is-correct { color: var(--green); }
.atp-ch.is-wrong {
  color: var(--red);
  background: var(--red-light);
  border-radius: 3px;
}

/* ── Hidden input (mobile focus trigger) ── */
.atp-input {
  width: 100%;
  margin-top: .75rem;
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-family: var(--mono);
  font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  caret-color: var(--blue);
}
.atp-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.14);
}

/* ── Keyboard wrapper ── */
.atp-kbdWrap {
  padding: .75rem 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}
.atp-kbdScroll { overflow-x: auto; padding-bottom: .4rem; }

/* ── Keyboard ── */
.atp-kbd {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  min-width: 706px;
  background: linear-gradient(180deg, #dde1eb, #c8cdd8);
  padding: 12px 12px 15px;
  border-radius: 14px;
  border: 1px solid #b8bfcc;
  box-shadow: 0 6px 20px rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.5);
}
.atp-kRow { display: flex; gap: 5px; align-items: flex-end; }

/* ── Key ── */
.atp-key {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 46px;
  border-radius: 7px;
  background: linear-gradient(180deg, #fff 0%, #f4f5fa 100%);
  border: 1px solid #c8cdd8;
  box-shadow: 0 2px 0 #a8adb8;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 700;
  color: #2d3446;
  cursor: default;
  user-select: none;
  transition: all .1s;
  flex-shrink: 0;
  line-height: 1;
  text-align: center;
}
.atp-key small { display: none; }
.atp-key--wide  { min-width: 64px; }
.atp-key--wider { min-width: 80px; font-size: .74rem; }
.atp-key--space { min-width: 330px; font-size: .74rem; color: var(--muted); }

/* ── Finger zone backgrounds ── */
.atp-key[data-finger="lp"] { background: linear-gradient(180deg,#f5f3ff,#ede9fe); border-color:#c4b5fd; }
.atp-key[data-finger="lr"] { background: linear-gradient(180deg,#eff6ff,#dbeafe); border-color:#93c5fd; }
.atp-key[data-finger="lm"] { background: linear-gradient(180deg,#f0fdfb,#ccfbf1); border-color:#5eead4; }
.atp-key[data-finger="li"] { background: linear-gradient(180deg,#f0fdf4,#dcfce7); border-color:#86efac; }
.atp-key[data-finger="ri"] { background: linear-gradient(180deg,#fefce8,#fef9c3); border-color:#fde047; }
.atp-key[data-finger="rm"] { background: linear-gradient(180deg,#fff7ed,#ffedd5); border-color:#fdba74; }
.atp-key[data-finger="rr"] { background: linear-gradient(180deg,#fff1f2,#fee2e2); border-color:#fca5a5; }
.atp-key[data-finger="rp"] { background: linear-gradient(180deg,#fdf2f8,#fce7f3); border-color:#f9a8d4; }

/* ── Key states ── */
.atp-key.is-target {
  background: linear-gradient(180deg,#3b82f6,#2563eb) !important;
  color: #fff !important;
  border-color: #1d4ed8 !important;
  box-shadow: 0 4px 0 #1e40af, 0 0 0 3px rgba(59,130,246,.35) !important;
  transform: translateY(-2px);
  z-index: 3;
}
.atp-key.is-pressed {
  transform: translateY(2px) !important;
  box-shadow: 0 0 0 #a8adb8 !important;
  opacity: .8;
}
.atp-key.is-wrong-pulse {
  background: linear-gradient(180deg,#fef2f2,#fee2e2) !important;
  border-color: #f87171 !important;
  color: var(--red) !important;
}

/* ── Finger guide strip ── */
.atp-fingerGuide {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin-top: .65rem;
  padding: .42rem .85rem;
  border-radius: 999px;
  background: #f8faff;
  border: 1px solid var(--border);
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
}
.atp-fingerGuide .fdot {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Keyboard legend ── */
.atp-kbdLegend {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem .6rem;
  margin-top: .6rem;
}
.atp-legendItem {
  display: flex;
  align-items: center;
  gap: .28rem;
  font-size: .74rem;
  color: var(--muted);
  font-weight: 600;
}
.atp-legendItem .fdot { width: 9px; height: 9px; border-radius: 50%; }

/* ── Result Modal ── */
.atp-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(5px);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.atp-modal.is-open { display: flex; }

.atp-modalCard {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem 1.75rem;
  width: min(460px, 100%);
  box-shadow: 0 24px 60px rgba(0,0,0,.22);
  border: 1px solid var(--border);
  text-align: center;
}
.atp-modalCard h2    { font-size: 1.5rem; font-weight: 800; margin-bottom: .3rem; }
.atp-modalCard > p   { color: var(--muted); margin-bottom: 1.4rem; font-size: .95rem; }

.atp-scoreGrid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .65rem;
  margin-bottom: 1.4rem;
}
.atp-scoreBox {
  padding: .9rem .5rem;
  border-radius: var(--radius-md);
  background: #f8faff;
  border: 1px solid var(--border);
}
.atp-scoreBox strong {
  display: block;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: .25rem;
}
.atp-scoreBox span {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
}
.atp-modalActions { display: flex; gap: .65rem; justify-content: center; }

/* ── Responsive ── */
@media (max-width: 860px) {
  .atp-stats { grid-template-columns: repeat(2, 1fr); }
  .atp-stat:nth-child(2) { border-right: none; }
  .atp-stat:nth-child(3) { border-right: 1px solid var(--border); }
}
@media (max-width: 580px) {
  .atp-hero   { padding: 1.3rem 1rem 1.1rem; }
  .atp-card   { border-radius: 14px; }
  .atp-topbar { padding: .75rem 1rem; flex-direction: column; align-items: flex-start; }
  .atp-controls { padding: .7rem 1rem; }
  .atp-typingCard { padding: 1rem; }
  .atp-words  { font-size: .92rem; padding: .85rem .75rem; line-height: 2.2; word-spacing: .45em; }
  .atp-kbdWrap{ padding: .5rem .75rem 1.2rem; }
  .atp-stat strong { font-size: 1.25rem; }
  .atp-btn    { padding: .5rem .9rem; }
  .atp-modalCard  { padding: 1.4rem 1.1rem 1.25rem; }
  .atp-scoreBox span { font-size: 1.35rem; }
}
@media (max-width: 380px) {
  .atp-words  { font-size: .84rem; }
  .atp-btn    { padding: .46rem .75rem; font-size: .82rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
