/* runtime-smoke-test — responsive demo calculator */
:root {
  --bg-1: #0f172a;
  --bg-2: #1d2a44;
  --card: #172033;
  --border: #2c3b55;
  --text: #e2e8f0;
  --muted: #8fa3bf;
  --btn: #2b3a55;
  --btn-hover: #38507a;
  --btn-fn: #22304a;
  --btn-fn-text: #aebfd8;
  --btn-op: #0d6d9e;
  --btn-op-hover: #0f82b8;
  --btn-eq: #17934c;
  --btn-eq-hover: #1cad5c;
  --display: #0c1524;
  --danger: #f87171;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.calc-wrap { width: 100%; display: flex; justify-content: center; }

.calc-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.55);
}

.calc-head { text-align: center; margin-bottom: 12px; }
.calc-head h1 {
  margin: 0 0 4px;
  font-size: clamp(1rem, 2.6vw, 1.15rem);
  letter-spacing: 0.02em;
}
.subtitle {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.calc-display {
  display: block;
  background: var(--display);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  text-align: right;
}
.calc-expression {
  min-height: 1.1em;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calc-result {
  font-size: clamp(1.7rem, 7vw, 2.3rem);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.calc-result.is-error { color: var(--danger); font-size: clamp(1.2rem, 5vw, 1.6rem); }

.calc-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  background: var(--btn);
  color: var(--text);
  font: inherit;
  font-size: clamp(1.1rem, 4.5vw, 1.35rem);
  font-weight: 500;
  padding: clamp(14px, 3.5vw, 18px) 0;
  min-height: 48px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 120ms ease, transform 60ms ease;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn-fn { background: var(--btn-fn); color: var(--btn-fn-text); }
.btn-op { background: var(--btn-op); }
.btn-eq { background: var(--btn-eq); font-weight: 700; }

@media (hover: hover) {
  .btn:hover { background: var(--btn-hover); }
  .btn-fn:hover { background: #2c3d5e; }
  .btn-op:hover { background: var(--btn-op-hover); }
  .btn-eq:hover { background: var(--btn-eq-hover); }
}

.btn:focus-visible,
.calc-display:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.calc-history { margin-top: 14px; }
.calc-history h2 {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.calc-history .hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 0.68rem;
}
.calc-history ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.calc-history li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  background: rgba(43, 58, 85, 0.45);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.calc-history li:hover { background: rgba(56, 80, 122, 0.55); }
.hist-expr { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist-res { font-variant-numeric: tabular-nums; }

.noscript-note { text-align: center; color: var(--muted); }

/* Larger screens */
@media (min-width: 480px) {
  .calc-card { max-width: 400px; padding: 20px; }
  body { padding: 24px; }
}

/* Short landscape screens (phones) — compact layout */
@media (max-height: 620px) and (orientation: landscape) {
  body { align-items: flex-start; }
  .calc-card { max-width: 460px; padding: 12px; }
  .calc-head { margin-bottom: 8px; }
  .btn { padding: 10px 0; min-height: 40px; }
  .calc-history ul { flex-direction: row; flex-wrap: wrap; }
  .calc-history li { flex: 1 1 40%; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:active { transform: none; }
}
