/* =========================================================
   Brighterly Fraction Calculator
   ========================================================= */

:root {
  /* ── Brighterly Brand Purple ── */
  --color-purple-50:  #F3F1FF;
  --color-purple-100: #E9E6FF;
  --color-purple-200: #D4CFFF;
  --color-purple-300: #B8B0FF;
  --color-purple-400: #9B91FF;
  --color-purple-500: #7B69FF;
  --color-purple-600: #6655E8;
  --color-purple-700: #5042C7;
  --color-purple-800: #3A2FA0;
  --color-purple-900: #211C6B;

  /* ── Accents ── */
  --color-emerald-500: #00BC7D;
  --color-amber-400:   #FBBF24;
  --color-slate-400:   #90A1B9;
  --color-blue-500:    #3B82F6;

  /* ── Neutrals ── */
  --color-white:      #FFFFFF;
  --color-gray-text:  #1E1B4B;
  --color-gray-muted: #6B7280;

  --focus-ring: 0 0 0 3px rgba(123, 105, 255, 0.18);
}

/* =========================================================
   Base — scoped to .brighterly-fc-root so theme styles
   outside the calculator are untouched
   ========================================================= */

.brighterly-fc-root,
.brighterly-fc-root *,
.brighterly-fc-root *::before,
.brighterly-fc-root *::after { box-sizing: border-box; }

.brighterly-fc-root {
  font-family: 'Rubik', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-weight: 400;
  font-size: 18px;
  line-height: 24px;
  color: var(--color-gray-text);
  background: var(--color-purple-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  border-radius: 24px;
  padding: 8px;
}

.brighterly-fc-root h1,
.brighterly-fc-root h2,
.brighterly-fc-root h3,
.brighterly-fc-root h4,
.brighterly-fc-root h5,
.brighterly-fc-root h6,
.brighterly-fc-root p { margin: 0; }

.brighterly-fc-root button { font-family: inherit; }

.brighterly-fc-root input[type="number"]::-webkit-outer-spin-button,
.brighterly-fc-root input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.brighterly-fc-root input[type="number"] { -moz-appearance: textfield; }

/* =========================================================
   Page layout
   ========================================================= */

.page-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

/* =========================================================
   Hero
   ========================================================= */

.page-hero {
  max-width: 800px;
  margin: 0 auto;
  padding: 64px 24px 40px;
  text-align: center;
}

.hero-badge {
  display: inline-block;
  background: var(--color-amber-400);
  color: var(--color-gray-text);
  font-weight: 500;
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.02em;
  padding: 8px 16px;
  border-radius: 9999px;
  margin-bottom: 20px;
}

.page-hero h1 {
  font-weight: 700;
  font-size: 64px;
  line-height: 72px;
  color: var(--color-gray-text);
  margin-bottom: 16px;
}

.hero-subtitle {
  font-weight: 400;
  font-size: 18px;
  line-height: 28px;
  color: var(--color-gray-muted);
  max-width: 560px;
  margin: 0 auto;
}

/* =========================================================
   Calculator card
   ========================================================= */

.calculator-card {
  background: var(--color-white);
  border: 1px solid var(--color-purple-200);
  border-radius: 24px;
  padding: 40px;
}

/* =========================================================
   Operation tabs
   ========================================================= */

.operation-tabs {
  display: flex;
  gap: 4px;
  background: var(--color-purple-50);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 28px;
}

.brighterly-fc-root .operation-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  font-family: 'Rubik', sans-serif;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  background: transparent;
  color: var(--color-gray-muted);
  white-space: nowrap;
  text-decoration: none;
  box-shadow: none;
}

/* Explicit color on inner span + svg so theme `.entry-content button span { color: ... }`
   rules can't override the active-state white text/icon. */
.brighterly-fc-root .operation-tab span,
.brighterly-fc-root .operation-tab svg { color: inherit; }

.brighterly-fc-root .operation-tab:hover,
.brighterly-fc-root .operation-tab:hover span { color: var(--color-purple-600); }

.brighterly-fc-root .operation-tab.active,
.brighterly-fc-root .operation-tab.active span,
.brighterly-fc-root .operation-tab.active svg {
  color: #FFFFFF;
}

.brighterly-fc-root .operation-tab.active {
  background: var(--color-purple-500);
}

.brighterly-fc-root .operation-tab:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.brighterly-fc-root .tab-icon { flex-shrink: 0; }

/* =========================================================
   Inputs row
   ========================================================= */

.inputs-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.fraction-input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--color-white);
  border: 1.5px solid var(--color-purple-200);
  border-radius: 12px;
  padding: 20px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.fraction-input-group:focus-within {
  border-color: var(--color-purple-500);
  box-shadow: 0 0 0 3px rgba(123, 105, 255, 0.12);
}

.fraction-input-group.has-error {
  border-color: #DC2626;
}

.fraction-group-title {
  font-family: 'Rubik', sans-serif;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-gray-muted);
  margin-bottom: 16px;
  text-align: center;
  width: 100%;
}

.fraction-fields-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.whole-wrap,
.fraction-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fraction-wrap {
  align-items: stretch;
  min-width: 72px;
}

.field-label {
  display: block;
  font-family: 'Rubik', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-gray-muted);
  text-align: center;
  margin-bottom: 4px;
}

.field-sublabel {
  display: block;
  font-size: 10px;
  color: var(--color-gray-muted);
  text-align: center;
  margin-top: 4px;
}

/* Whole input */
.whole-input {
  border: 1.5px solid var(--color-purple-200);
  border-radius: 8px;
  padding: 10px 8px;
  font-family: 'Rubik', sans-serif;
  font-size: 24px;
  font-weight: 500;
  color: var(--color-gray-text);
  width: 64px;
  min-height: 44px;
  text-align: center;
  background: var(--color-white);
  transition: border-color 0.2s, background 0.2s;
}

.whole-input::placeholder {
  color: var(--color-slate-400);
  font-weight: 500;
  opacity: 1;
}

.whole-input:focus {
  outline: none;
  border-color: var(--color-purple-500);
  background: var(--color-purple-50);
}

/* Numerator / denominator inputs */
input.fraction-field {
  border: 1.5px solid var(--color-purple-200);
  border-radius: 8px;
  padding: 10px 8px;
  font-family: 'Rubik', sans-serif;
  font-size: 24px;
  font-weight: 500;
  color: var(--color-gray-text);
  width: 72px;
  min-height: 44px;
  text-align: center;
  background: var(--color-white);
  transition: border-color 0.2s, background 0.2s;
}

input.fraction-field::placeholder {
  color: var(--color-purple-300);
  opacity: 1;
}

input.fraction-field:focus {
  outline: none;
  border-color: var(--color-purple-500);
  background: var(--color-purple-50);
}

.fraction-divider-line {
  width: 100%;
  height: 2px;
  background: var(--color-purple-200);
  border-radius: 1px;
  margin: 4px 0;
}

.input-error {
  min-height: 16px;
  margin-top: 8px;
  color: #DC2626;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
}

/* Operator between fractions */
.operator-symbol {
  font-family: 'Rubik', sans-serif;
  font-weight: 700;
  font-size: 36px;
  color: var(--color-purple-500);
  flex-shrink: 0;
  user-select: none;
  padding: 0 4px;
}

/* =========================================================
   Calculate button
   ========================================================= */

.calculate-btn {
  background: var(--color-purple-500);
  color: var(--color-white);
  border: none;
  border-radius: 12px;
  padding: 16px 40px;
  font-family: 'Rubik', sans-serif;
  font-weight: 600;
  font-size: 18px;
  cursor: pointer;
  width: 100%;
  margin-top: 24px;
  min-height: 56px;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}

.calculate-btn:hover {
  background: var(--color-purple-600);
  transform: scale(1.02);
}

.calculate-btn:active { transform: scale(0.98); }

.calculate-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* =========================================================
   Result card
   ========================================================= */

.result-card {
  background: var(--color-white);
  border-radius: 20px;
  border: 1px solid var(--color-purple-200);
  border-left: 5px solid var(--color-emerald-500);
  padding: 24px 28px;
  margin-top: 24px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  display: none;
}

.result-card.visible {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.result-label {
  font-family: 'Rubik', sans-serif;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--color-emerald-500);
  margin-bottom: 12px;
  text-align: left;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.result-equals {
  font-family: 'Rubik', sans-serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--color-purple-500);
  line-height: 1;
}

.result-fraction {
  display: inline-flex;
  align-items: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--color-gray-text);
  line-height: 1.2;
}

.result-fraction .fraction-display { font-size: 24px; }

.result-decimal {
  font-family: 'Rubik', sans-serif;
  font-size: 16px;
  font-weight: 400;
  color: var(--color-gray-muted);
}

/* =========================================================
   Step-by-step
   ========================================================= */

.steps-container { margin-top: 32px; }

.steps-heading {
  font-family: 'Rubik', sans-serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--color-gray-text);
  margin-bottom: 20px;
}

.steps-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.step-item {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  align-items: flex-start;
}

.step-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-purple-500);
  color: var(--color-white);
  font-family: 'Rubik', sans-serif;
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-body { flex: 1; min-width: 0; }

.step-title {
  font-family: 'Rubik', sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--color-blue-500);
  margin-bottom: 8px;
}

.step-content {
  font-size: 16px;
  line-height: 24px;
  color: var(--color-gray-text);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* =========================================================
   Stacked fraction display (used in steps + result)
   ========================================================= */

.fraction-display {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 4px;
  line-height: 1.2;
  min-width: 14px;
}

.fraction-num,
.fraction-den {
  font-weight: 600;
  padding: 0 4px;
}

.fraction-bar {
  width: 100%;
  height: 2px;
  background: currentColor;
  margin: 2px 0;
}

/* =========================================================
   Responsive — mobile ≤ 768px
   ========================================================= */

@media (max-width: 768px) {
  .page-hero { padding: 40px 16px 28px; }
  .page-hero h1 { font-size: 36px; line-height: 44px; }
  .hero-subtitle { font-size: 16px; line-height: 22px; }

  .page-container { padding: 0 16px 48px; }

  .calculator-card { padding: 24px; border-radius: 20px; }

  .operation-tab {
    font-size: 12px;
    padding: 10px 6px;
    gap: 4px;
  }
  .operation-tab span { font-size: 12px; }

  .inputs-row {
    flex-direction: column;
    gap: 12px;
  }

  .operator-symbol { font-size: 28px; }

  .whole-input { width: 56px; font-size: 22px; }
  input.fraction-field { width: 64px; font-size: 22px; }

  .result-card { padding: 20px; }
  .result-equals { font-size: 22px; }
  .result-fraction { font-size: 22px; }
  .result-fraction .fraction-display { font-size: 22px; }

  .steps-heading { font-size: 18px; }
  .step-title { font-size: 15px; }
  .step-content { font-size: 15px; line-height: 22px; }
}

@media (max-width: 420px) {
  .operation-tabs { flex-wrap: wrap; }
  .operation-tab { flex: 1 1 calc(50% - 4px); }
}
