/* ===================================================================
   Grade Calculator – Professional Minimal Theme v2
   Fully self-contained under .gc-wrap — zero theme / sidebar leaks.
   =================================================================== */

/* ---------- Design Tokens ---------- */
.gc-wrap {
  --pink: #F71FC6;
  --mint: #47D395;
  --grad: linear-gradient(135deg, var(--pink) 0%, #b93fe0 50%, var(--mint) 100%);
  --grad-subtle: linear-gradient(135deg, rgba(247,31,198,.08), rgba(71,211,149,.08));

  --ink: #14151C;
  --ink-mid: #3D3F4B;
  --ink-soft: #6B7080;
  --line: #E8EAF0;
  --line-strong: #D0D3DC;
  --surface: #FFFFFF;
  --surface-raised: #F6F7FA;
  --surface-hover: #F0F1F5;
  --ring-pink: rgba(247, 31, 198, .08);
  --ring-mint: rgba(71, 211, 149, .08);
  --shadow-sm: 0 1px 3px rgba(20,21,28,.04), 0 1px 2px rgba(20,21,28,.06);
  --shadow-md: 0 4px 16px rgba(20,21,28,.06), 0 1px 3px rgba(20,21,28,.04);
  --shadow-lg: 0 12px 40px rgba(20,21,28,.10), 0 4px 12px rgba(20,21,28,.05);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* System font stack */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* Containment — prevents sidebar / theme bleed */
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 0 48px;
  line-height: 1.55;
  position: relative;
  isolation: isolate;
  contain: layout style;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .gc-wrap:not([data-theme="light"]) {
    --ink: #EDEEF3;
    --ink-mid: #B0B3C0;
    --ink-soft: #7F839A;
    --line: #262833;
    --line-strong: #353845;
    --surface: #15161D;
    --surface-raised: #1B1C25;
    --surface-hover: #22232E;
    --ring-pink: rgba(247, 31, 198, .12);
    --ring-mint: rgba(71, 211, 149, .10);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,.25);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.35);
  }
}

/* ---------- Reset (scoped) ---------- */
.gc-wrap *,
.gc-wrap *::before,
.gc-wrap *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.gc-wrap [hidden] {
  display: none !important;
}

.gc-wrap button {
  font-family: inherit;
}

/* ---------- Header ---------- */
.gc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.gc-title {
  font-weight: 800;
  font-size: 1.4rem;
  line-height: 1.25;
  letter-spacing: -0.025em;
  margin: 0;
  padding: 0;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ---------- Gear (settings) button ---------- */
.gc-gear {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .2s var(--ease);
  padding: 0;
  box-shadow: var(--shadow-sm);
}

.gc-gear:hover {
  border-color: var(--pink);
  color: var(--pink);
  box-shadow: var(--shadow-md);
  transform: rotate(45deg);
}

.gc-gear[aria-expanded="true"] {
  border-color: var(--pink);
  background: var(--ring-pink);
  color: var(--pink);
  transform: rotate(90deg);
}

.gc-gear svg {
  width: 16px;
  height: 16px;
  transition: transform .25s var(--ease);
}

.gc-gear:focus-visible,
.gc-wrap input:focus-visible,
.gc-wrap button:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

/* ---------- Main Card ---------- */
.gc-card {
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .25s var(--ease);
}

.gc-card:hover {
  box-shadow: var(--shadow-md);
}

.gc-card-label {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 16px;
}

/* ---------- Column Headers & Rows ---------- */
.gc-col-labels,
.gc-row {
  display: grid;
  grid-template-columns: 24px 1fr 96px 30px;
  gap: 10px;
  align-items: center;
}

.gc-col-labels {
  padding-bottom: 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.gc-row {
  padding: 6px 0;
  animation: gc-fadeIn .25s var(--ease) both;
}

@keyframes gc-fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gc-row-idx {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: center;
  width: 24px;
  height: 24px;
  line-height: 24px;
  border-radius: 50%;
  background: var(--surface-raised);
}

/* ---------- Inputs ---------- */
.gc-row input {
  width: 100%;
  background: var(--surface-raised);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-xs);
  color: var(--ink);
  font-size: 0.88rem;
  padding: 9px 12px;
  font-family: inherit;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease);
}

.gc-row input::placeholder {
  color: var(--ink-soft);
  opacity: 0.5;
}

.gc-row input:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.gc-row input:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px var(--ring-mint);
  background: var(--surface);
  outline: none;
}

.gc-row input.gc-invalid {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--ring-pink);
  background: var(--surface);
}

/* Percentage wrapper */
.gc-pct {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gc-pct span {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 500;
}

/* ---------- Delete button ---------- */
.gc-del {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all .2s var(--ease);
  padding: 0;
  opacity: 0.5;
}

.gc-del:hover {
  color: var(--pink);
  background: var(--ring-pink);
  opacity: 1;
  transform: scale(1.1);
}

.gc-del svg {
  width: 14px;
  height: 14px;
}

/* ---------- Add Row button ---------- */
.gc-add {
  margin: 12px 0 0;
  border: 1.5px dashed var(--line-strong);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  width: 100%;
  text-align: center;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s var(--ease);
  letter-spacing: 0.01em;
}

.gc-add:hover {
  border-color: var(--mint);
  color: var(--mint);
  background: var(--ring-mint);
}

/* ---------- Inline Messages ---------- */
.gc-msg {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--pink);
  background: var(--ring-pink);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--ink);
  animation: gc-fadeIn .2s var(--ease);
}

.gc-msg ul {
  margin: 0;
  padding-left: 16px;
}

/* ---------- Action Buttons ---------- */
.gc-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

.gc-btn {
  font-size: 0.88rem;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s var(--ease);
  letter-spacing: 0.01em;
}

.gc-btn:active {
  transform: scale(0.97);
}

.gc-btn--primary {
  color: #FFFFFF;
  background: var(--grad);
  box-shadow: 0 2px 8px rgba(247, 31, 198, .2);
  position: relative;
  overflow: hidden;
}

.gc-btn--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.15), transparent 60%);
  pointer-events: none;
}

.gc-btn--primary:hover {
  box-shadow: 0 4px 16px rgba(247, 31, 198, .3);
  transform: translateY(-1px);
}

.gc-btn--secondary {
  border: 1.5px solid var(--line-strong);
  color: var(--ink-mid);
  background: var(--surface);
}

.gc-btn--secondary:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: var(--surface-hover);
}

/* ================================================================
   RESULT SECTION
   ================================================================ */
.gc-result {
  margin-top: 24px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  animation: gc-slideUp .35s var(--ease) both;
}

@keyframes gc-slideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gc-result__stripe {
  height: 3px;
  background: var(--grad);
}

.gc-result.gc-bad .gc-result__stripe {
  background: var(--pink);
}

.gc-result__body {
  padding: 28px 28px 24px;
  text-align: center;
}

.gc-result__kicker {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.gc-result__value {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-weight: 700;
  font-size: 3rem;
  line-height: 1;
  letter-spacing: -0.03em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.gc-result.gc-bad .gc-result__value {
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  -webkit-text-fill-color: initial;
  color: var(--pink);
}

.gc-result__detail {
  margin: 16px auto 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
  max-width: 38ch;
  line-height: 1.65;
}

.gc-result__detail strong {
  color: var(--ink);
  font-weight: 600;
}

/* Stats bar */
.gc-result__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  background: var(--surface-raised);
}

.gc-stat {
  padding: 16px 18px;
  text-align: center;
  transition: background .2s var(--ease);
}

.gc-stat:hover {
  background: var(--surface-hover);
}

.gc-stat + .gc-stat {
  border-left: 1px solid var(--line);
}

.gc-stat__number {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color: var(--ink);
}

.gc-stat__label {
  display: block;
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--ink-soft);
  margin-top: 3px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ================================================================
   SETTINGS MODAL
   ================================================================ */
.gc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 14, .5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 99999;
  animation: gc-fadeOverlay .2s var(--ease);
}

@keyframes gc-fadeOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gc-modal {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: gc-modalIn .3s var(--ease) both;
}

@keyframes gc-modalIn {
  from {
    opacity: 0;
    transform: scale(.95) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.gc-modal__stripe {
  height: 3px;
  background: var(--grad);
}

.gc-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 0;
}

.gc-modal h2 {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.gc-modal__sub {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 5px 0 0;
  line-height: 1.5;
}

.gc-modal__close {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  border: none;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: all .2s var(--ease);
}

.gc-modal__close:hover {
  color: var(--pink);
  background: var(--ring-pink);
  transform: rotate(90deg);
}

.gc-modal__close svg {
  width: 14px;
  height: 14px;
}

/* Settings Fields */
.gc-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 18px 22px 0;
}

.gc-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

.gc-field input {
  width: 100%;
  background: var(--surface-raised);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 9px 12px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.gc-field input:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 3px var(--ring-mint);
  outline: none;
}

/* Modal msg reuse */
.gc-modal .gc-msg {
  margin: 14px 22px 0;
}

/* Modal action buttons */
.gc-modal__actions {
  display: flex;
  gap: 8px;
  padding: 18px 22px 20px;
}

.gc-mbtn {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 9px 12px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-xs);
  color: var(--ink-mid);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s var(--ease);
  letter-spacing: 0.01em;
}

.gc-mbtn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: var(--surface-hover);
}

.gc-mbtn--save {
  border: none;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--grad);
  box-shadow: 0 2px 8px rgba(247, 31, 198, .15);
}

.gc-mbtn--save:hover {
  box-shadow: 0 4px 12px rgba(247, 31, 198, .25);
  transform: translateY(-1px);
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .gc-wrap {
    padding: 20px 0 32px;
  }

  .gc-title {
    font-size: 1.15rem;
  }

  .gc-card {
    padding: 18px 16px;
  }

  .gc-col-labels,
  .gc-row {
    grid-template-columns: 20px 1fr 80px 28px;
    gap: 6px;
  }

  .gc-result__value {
    font-size: 2.4rem;
  }

  .gc-result__body {
    padding: 22px 20px 18px;
  }

  .gc-fields {
    grid-template-columns: 1fr;
  }
}

/* ---------- WordPress Sidebar Containment ---------- */
/* Prevent the tool from breaking in WordPress layouts with sidebars */
.gc-wrap,
.gc-wrap * {
  float: none !important;
}

/* Ensure inputs don't inherit weird WP theme widths */
.gc-wrap input[type="number"] {
  min-width: 0;
  max-width: 100%;
  -moz-appearance: textfield;
}

.gc-wrap input[type="number"]::-webkit-outer-spin-button,
.gc-wrap input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Override common WP theme button resets */
.gc-wrap button {
  line-height: inherit;
  text-decoration: none;
  box-shadow: none;
  text-shadow: none;
}

.gc-wrap button:focus {
  box-shadow: none;
}
