/* ===================================================================
   Random Number Generator — Premium Design
   Zero dependencies. Pure CSS.
   =================================================================== */

/* ============ Design tokens ============ */
:root {
  --bg:           #faf6f1;
  --bg-2:         #f3eee5;
  --surface:      #ffffff;
  --surface-2:    #faf6ed;
  --surface-3:    #eee7d8;
  --border:       #e8dfcc;
  --border-soft:  #f0e9da;
  --text:         #1f1a14;
  --text-2:       #5c5547;
  --text-3:       #6e6557;
  --text-faint:   #b5ac9b;
  --accent:       #e85f4d;
  --accent-2:     #d44a39;
  --accent-soft:  rgba(232,95,77,0.10);
  --accent-glow:  rgba(232,95,77,0.30);
  --success:      #3a9d6f;
  --r-sm: 8px;
  --r-md: 12px;
  --r-xl: 20px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 24px 48px rgba(0,0,0,0.12);
  --transition: 200ms cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 400ms cubic-bezier(0.4,0,0.2,1);
  --font-ui: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "PingFang TC", "PingFang SC", "Hiragino Sans", "Noto Sans CJK", sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* ============ Reset ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
html, body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-2); }
ul, ol { list-style: none; }
[hidden] { display: none !important; }

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px; top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-weight: 600;
  border-radius: 0 0 var(--r-sm) 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

/* ============ Body gradient ============ */
body {
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 235, 220, 0.55) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

/* ============ App layout ============ */
.app {
  max-width: 580px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px) clamp(12px, 3vw, 24px) 80px;
}

/* ============ Top bar ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px 28px;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-2);
}
.brand:hover { color: var(--accent); }

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover {
  color: var(--accent);
  background: var(--surface-2);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switcher {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%237a7973' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  transition: border-color var(--transition);
}
.lang-switcher:hover { border-color: var(--text-3); }
.lang-switcher:focus { outline: none; border-color: var(--accent); }

/* ============ Page title ============ */
.page-title {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 6px;
}
.page-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 36px;
}

/* ============ Workspace ============ */
.workspace {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 64px;
}

/* ============ Input card ============ */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: clamp(24px, 4vw, 32px) clamp(20px, 4vw, 28px);
}

/* Range inputs row */
.range-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 20px;
}
.range-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.range-field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.range-field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  -moz-appearance: textfield;
}
.range-field input::-webkit-inner-spin-button,
.range-field input::-webkit-outer-spin-button {
  opacity: 1;
  height: 30px;
}
.range-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.range-field input.invalid {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.range-divider {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-3);
  padding-bottom: 14px;
}

/* Generate button */
.generate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 16px 32px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-md);
  font-size: 16px;
  font-weight: 600;
  transition: background var(--transition), transform 80ms ease-out, box-shadow var(--transition);
  box-shadow: 0 4px 12px var(--accent-glow);
}
.generate-btn:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
}
.generate-btn:active { transform: translateY(0) scale(0.98); }
.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.generate-btn svg { width: 20px; height: 20px; }

/* ============ Result card — light Tomato Hero ============ */
.result-card {
  --screen-bg-1: #fff4ec;
  --screen-bg-2: #f6e6d6;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 18px 18px 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  min-height: 220px;
  display: flex;
  flex-direction: column;
}

.result-bezel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 10px;
  position: relative;
}

.result-label {
  font-size: 10px;
  letter-spacing: 0.22em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-3);
}

.result-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  box-shadow: var(--shadow-sm);
  transition: color var(--transition), transform 80ms ease-out, background var(--transition), border-color var(--transition);
  position: relative;
}
.result-copy:hover { color: var(--accent); border-color: var(--accent); }
.result-copy:active { transform: translateY(1px); }
.result-copy svg { width: 14px; height: 14px; }
.result-copy .icon-check { display: none; color: var(--accent); }
.result-copy.is-copied .icon-copy { display: none; }
.result-copy.is-copied .icon-check { display: block; }

.result-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 90% 70% at 50% 35%, var(--screen-bg-1) 0%, var(--screen-bg-2) 100%);
  border-radius: var(--r-md);
  padding: 22px 16px;
  min-height: 150px;
  position: relative;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 3px rgba(40, 28, 20, 0.08);
  overflow: hidden;
}
.result-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg,
      rgba(40, 28, 20, 0.025) 0px,
      rgba(40, 28, 20, 0.025) 1px,
      transparent 1px,
      transparent 3px);
  pointer-events: none;
  border-radius: 14px;
}
.result-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35) 0%, transparent 22%);
  pointer-events: none;
  border-radius: 14px;
}

.result-number {
  position: relative;
  font-family: var(--font-mono);
  font-size: clamp(60px, 15vw, 108px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums slashed-zero;
  text-shadow:
    0 0 12px rgba(232, 95, 77, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1;
}

.result-number.is-animating {
  animation: result-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes result-pop {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.result-empty {
  position: relative;
  font-size: 14px;
  color: rgba(40, 28, 20, 0.42);
  font-weight: 500;
  letter-spacing: 0.02em;
  z-index: 1;
}

/* ============ Quick presets ============ */
.presets-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px 24px;
}
.presets-card h3 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 12px;
}
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.preset-chip {
  padding: 8px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background var(--transition), border-color var(--transition), transform 80ms ease-out;
}
.preset-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent-glow);
  color: var(--accent);
}
.preset-chip:active { transform: scale(0.96); }
.preset-chip.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============ History ============ */
.history-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px 24px;
}
.history-section h3 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 12px;
}
.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
  align-items: center;
}
.history-item {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  background: linear-gradient(180deg, #ffffff 0%, var(--surface-2) 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-pill);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums slashed-zero;
  font-family: var(--font-mono);
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 1px 1px rgba(40, 28, 20, 0.04);
  transition: transform 120ms ease-out, border-color var(--transition), box-shadow var(--transition);
}
.history-item:hover {
  border-color: var(--accent-glow);
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 3px 8px rgba(232, 95, 77, 0.10);
}
.history-item:first-child {
  background: linear-gradient(180deg, #fff1ed 0%, #ffe2da 100%);
  border-color: var(--accent-glow);
  color: var(--accent-2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 1px 3px rgba(232, 95, 77, 0.14);
}
.history-empty {
  font-size: 13px;
  color: var(--text-3);
  font-style: italic;
}

/* ============ Info / SEO section ============ */
.info {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 0;
  color: var(--text-2);
  line-height: 1.7;
}
.info h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin: 36px 0 12px;
}
.info h2:first-child { margin-top: 0; }
.info p { margin-bottom: 14px; font-size: 15px; }
.info h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 20px 0 8px;
}
.info ol {
  margin-bottom: 14px;
  padding-left: 0;
  counter-reset: step;
}
.info ol li {
  padding: 6px 0 6px 32px;
  position: relative;
  list-style: none;
  font-size: 15px;
}
.info ol li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0; top: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 22px;
}

/* FAQ accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color var(--transition);
}
.faq-item:hover { border-color: var(--text-3); }

.faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
  gap: 12px;
  transition: background var(--transition);
}
.faq-question:hover { background: var(--surface-2); }
.faq-question svg {
  flex-shrink: 0;
  width: 16px; height: 16px;
  color: var(--text-3);
  transition: transform var(--transition);
}
.faq-item.is-open .faq-question svg {
  transform: rotate(45deg);
}

.faq-answer {
  display: none;
  padding: 0 16px 14px;
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
}
.faq-item.is-open .faq-answer {
  display: block;
}

/* ============ Footer ============ */
.site-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}
.site-footer-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 6px;
}
.site-footer a { color: var(--text-2); }
.site-footer a:hover { color: var(--accent); }
.site-footer .sub {
  font-size: 11px;
  color: var(--text-faint);
}

/* ============ Responsive ============ */
@media (max-width: 600px) {
  .app { padding: 8px 12px 60px; }
  .topbar { padding: 4px 0 20px; }
  .lang-switcher { padding: 4px 22px 4px 8px; font-size: 12px; max-width: 140px; text-overflow: ellipsis; }
  .page-sub { margin-bottom: 24px; }
  .range-row { flex-direction: column; gap: 8px; }
  .range-divider { display: none; }
  .result-card { padding: 14px 14px 18px; min-height: 190px; }
  .result-screen { min-height: 130px; padding: 18px 12px; }
  .info { padding: 16px 4px; }
  .info h2 { font-size: 20px; margin-top: 28px; }
}

@media (max-width: 420px) {
  .topbar-right .nav-link { display: none; }
  .topbar-right { gap: 6px; }
  .lang-switcher { max-width: 130px; }
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ Focus visible ============ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus:not(:focus-visible),
select:focus:not(:focus-visible),
input:focus:not(:focus-visible) { outline: none; }
