/* Percentage Increase & Decrease Calculator — v1 */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #e0e7ff;
  --increase: #059669;
  --increase-soft: #d1fae5;
  --decrease: #dc2626;
  --decrease-soft: #fee2e2;
  --radius: 1.25rem;
  --radius-sm: 0.75rem;
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.08);
  --focus: 0 0 0 3px rgba(79, 70, 229, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-soft: #312e81;
    --increase: #34d399;
    --increase-soft: #064e3b;
    --decrease: #f87171;
    --decrease-soft: #7f1d1d;
    --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.35);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--surface);
  color: var(--primary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  z-index: 100;
}

.skip-link:focus {
  top: 1rem;
}

.container {
  width: min(1100px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.logo {
  font-weight: 800;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.logo:hover {
  color: var(--primary);
}

.nav-main {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.nav-main a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.25rem 0;
}

.nav-main a:hover {
  color: var(--primary);
}

.hero {
  padding: 3rem 0 1.5rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(1.875rem, 5vw, 3rem);
  line-height: 1.1;
  margin: 0 0 0.75rem;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.hero p {
  font-size: 1.1875rem;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: clamp(1.5rem, 4vw, 2.75rem);
  margin: 1.5rem 0 3rem;
  position: relative;
  overflow: hidden;
}

.tool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--primary-hover));
}

.calculator-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .calculator-grid {
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: end;
  }
}

.swap-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
}

.swap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.swap-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.swap-btn:active {
  transform: scale(0.95);
}

.swap-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field-group label {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.field-group input,
.field-group select {
  width: 100%;
  padding: 1rem 1.125rem;
  font-size: 1.25rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-group input:hover,
.field-group select:hover {
  border-color: #cbd5e1;
}

.field-group input:focus,
.field-group select:focus {
  border-color: var(--primary);
}

.field-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.result-panel {
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 200px;
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
  position: relative;
}

.result-panel.is-increase {
  background: var(--increase-soft);
  border-color: color-mix(in srgb, var(--increase) 25%, transparent);
}

.result-panel.is-decrease {
  background: var(--decrease-soft);
  border-color: color-mix(in srgb, var(--decrease) 25%, transparent);
}

.result-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.result-panel__header .result-panel__label {
  margin-bottom: 0;
}

.result-panel__value {
  font-size: clamp(2.25rem, 7vw, 3.5rem);
  font-weight: 800;
  line-height: 1.05;
  margin: 0 0 0.375rem;
  letter-spacing: -0.02em;
}

.result-panel__label {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-panel__sentence {
  font-size: 1rem;
  color: var(--text);
  margin: 0;
}

.result-panel__detail {
  margin-top: 0.75rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.copy-btn {
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}

.copy-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.copy-btn.is-copied {
  color: var(--increase);
  border-color: var(--increase);
  background: var(--increase-soft);
}

.copy-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.copy-btn[hidden] {
  display: none;
}

.result-panel__empty {
  color: var(--text-muted);
  text-align: center;
}

.extras {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.extras summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--primary);
}

.extras[open] summary {
  margin-bottom: 1rem;
}

.extra-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .extra-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.extra-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.extra-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.extra-card output {
  font-size: 1.25rem;
  font-weight: 700;
}

.formula {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.formula__label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.formula__body {
  color: var(--text-muted);
}

.formula code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
}

.presets {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.presets__title {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-muted);
}

.presets__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset {
  padding: 0.5rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.preset:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.preset:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

@media (max-width: 640px) {
  .formula {
    margin-top: 1rem;
    padding: 0.75rem;
    font-size: 0.875rem;
  }

  .presets {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
  }

  .presets__chips {
    gap: 0.375rem;
  }

  .preset {
    font-size: 0.875rem;
    padding: 0.4375rem 0.75rem;
  }
}

.section {
  padding: 3rem 0;
}

.section--alt {
  background: var(--surface);
  border-block: 1px solid var(--border);
  box-shadow: inset 0 1px 0 0 rgb(255 255 255 / 0.05);
}

.section h2 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin: 0 0 1.25rem;
  letter-spacing: -0.02em;
}

.lead {
  color: var(--text-muted);
  max-width: 70ch;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.9375rem;
  margin-bottom: 1rem;
}

.faq-accordion {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--primary);
  line-height: 1;
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  content: '−';
}

.faq-item summary:hover {
  background: var(--bg);
}

.faq-item summary h3 {
  font-size: 1.0625rem;
  margin: 0;
  letter-spacing: -0.01em;
  font-weight: 600;
}

.faq-item p {
  margin: 0;
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .faq-item summary {
    padding: 0.875rem 1rem;
  }

  .faq-item summary h3 {
    font-size: 1rem;
  }

  .faq-item p {
    padding: 0 1rem 1rem;
  }
}

/* No-JS fallback: FAQ accordion works natively without JavaScript */

.contact {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 4vw, 2rem);
  max-width: 640px;
  margin: 0 auto;
}

.contact h2 {
  margin-top: 0;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  font: inherit;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}

.contact-form textarea {
  min-height: 120px;
  resize: vertical;
}

.contact-form button {
  align-self: flex-start;
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.contact-form button:hover {
  background: var(--primary-hover);
}

.contact-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-status {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  display: none;
}

.form-status.is-visible {
  display: block;
}

.form-status--success {
  background: var(--increase-soft);
  color: var(--increase);
}

.form-status--error {
  background: var(--decrease-soft);
  color: var(--decrease);
}

.hp {
  position: absolute;
  left: -9999px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.site-footer a {
  color: var(--text-muted);
  margin: 0 0.75rem;
}

.site-footer a:hover {
  color: var(--primary);
}

.legal-page {
  max-width: 70ch;
  margin: 0 auto;
  padding: 2.5rem 1rem;
}

.legal-page h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.legal-page h2 {
  font-size: 1.25rem;
  margin-top: 2rem;
}

.legal-page p,
.legal-page li {
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .site-header {
    padding: 1rem 0;
  }

  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .logo {
    font-size: 1.0625rem;
  }

  .nav-main {
    width: 100%;
    justify-content: flex-start;
  }

  .nav-main a {
    font-size: 0.875rem;
  }

  .hero {
    padding-top: 1.75rem;
  }

  .tool-card {
    padding: 1.25rem;
  }

  [role="tablist"] {
    gap: 0.25rem;
  }

  [role="tab"] {
    padding: 0.75rem 0.875rem;
    font-size: 0.9375rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
