/* ──────────────────────────────────────────────────────────────────────── */
/*  Forge a Circle of Sorcery — ecosystem mages guild generator             */
/* ──────────────────────────────────────────────────────────────────────── */

.mg-page { max-width: 1300px; margin: 0 auto; }

/* Header */
.mg-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap;
  padding-bottom: 1.1rem; border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.mg-head-kicker {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .25rem .7rem; border-radius: 999px;
  border: 1px solid rgba(139,112,255,.32); background: rgba(139,112,255,.08);
  color: #b29cff; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; margin-bottom: .5rem;
}
.mg-head-title h1 {
  margin: 0 0 .4rem; font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 10%, #d7c7ff 45%, #f0cf7d 80%, #9fd8ff 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.mg-head-sub { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; max-width: 640px; }
.mg-head-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* Buttons */
.mg-btn, .mg_btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem 1rem; border-radius: 10px;
  font-size: .84rem; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all .16s ease; white-space: nowrap;
  border: 1px solid transparent;
  background: transparent; color: var(--muted); border-color: var(--border);
}
.mg-btn:hover, .mg_btn:hover { color: var(--text); border-color: var(--gold); background: rgba(214,178,87,.06); }
.mg-btn-primary {
  background: linear-gradient(135deg, #a589ff 0%, var(--violet) 55%, #6a4df4 100%);
  color: #fff; border-color: rgba(139,112,255,.55);
  box-shadow: 0 3px 14px rgba(139,112,255,.3);
}
.mg-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 22px rgba(139,112,255,.45); }
.mg_btn.secondary { color: var(--muted); }
.mg-btn:disabled, .mg_btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* Context controls */
.mg-controls {
  display: flex; flex-wrap: wrap; gap: 1rem 1.2rem;
  padding: 1rem 1.15rem; border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(26,26,45,.65), rgba(19,19,33,.65));
  margin-bottom: 1.25rem; align-items: flex-end;
}
.mg-field { display: flex; flex-direction: column; gap: .35rem; min-width: 160px; flex: 1 1 180px; }
.mg-field-label {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}
.mg-select {
  padding: .55rem .75rem;
  background: rgba(8,8,14,.65); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text);
  font-size: .88rem; font-family: inherit; outline: none;
  transition: border-color .15s ease; width: 100%;
}
.mg-select:focus { border-color: var(--gold); }

/* Cards (shared) — use both mg_card and mg_cardBorderBottom */
.mg_card {
  background: linear-gradient(180deg, var(--panel-top), var(--panel));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem 1.4rem 1.35rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
  margin-bottom: 1.25rem;
}
.mg_cardBorderBottom { border-left: 3px solid rgba(139,112,255,.4); }
.tg_cardBorder { border-left: 3px solid rgba(214,178,87,.4); }
.mg_cardSoftBand { background: linear-gradient(180deg, rgba(139,112,255,.05), var(--panel)); }

.mg_title { font-family: var(--display); font-size: 1.15rem; color: var(--gold-hi); letter-spacing: .02em; }
.mg_varText { color: var(--gold); }
.mg_structureTitle { font-family: var(--display); font-size: 1.15rem; color: var(--gold-hi); letter-spacing: .02em; }
.mg_structureNote { color: var(--muted); font-style: italic; line-height: 1.55; margin-bottom: .8rem; }
.mg_h2 { font-family: var(--display); font-size: 1.15rem; color: var(--gold-hi); letter-spacing: .02em; margin: 0 0 .7rem; }
.mg_h3 { font-family: var(--display); font-size: 1.02rem; color: var(--gold); letter-spacing: .02em; border-bottom: 1px solid var(--border-soft); padding-bottom: .4rem; margin: 0 0 .6rem; }
.mg_small { font-size: .82rem; }

.tg_indent5 { padding-left: 1.25rem; }

.mg_guildTitle {
  font-family: var(--display); font-size: clamp(1.5rem, 2.4vw, 2rem);
  color: var(--gold-hi); letter-spacing: .02em; margin: 0 0 .4rem;
  line-height: 1.15;
}

/* Identity row: heraldry + overview */
.mg_identity { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.mg_identity-symbol { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: .6rem; min-width: 200px; }
.mg_identity-body   { flex: 1 1 500px; min-width: 0; }

.heraldry_wrap { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.heraldry_frame {
  position: relative; border-radius: 14px; overflow: hidden;
  background: rgba(255,255,255,.02); display: inline-block;
}
.heraldry_frame .hs_inner { position: relative; display: block; }
.heraldry_frame .heraldry_banner { display: block; max-width: 100%; height: auto; }
.heraldry_reroll {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .85rem; border-radius: 8px;
  font-size: .78rem; font-weight: 700; color: var(--muted);
  border: 1px solid var(--border); background: rgba(255,255,255,.02);
  font-family: inherit; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.heraldry_reroll:hover { color: var(--gold); border-color: var(--gold); background: rgba(214,178,87,.06); }

/* Tables */
.mg_table { width: 100%; border-collapse: collapse; }
.mg_table td { padding: .5rem .55rem; border-bottom: 1px solid var(--border-soft); vertical-align: top; font-size: .88rem; }
.mg_table tr:last-child td { border-bottom: none; }
.mg_label { width: 200px; color: var(--gold); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.mg_data  { color: var(--text); line-height: 1.55; }
.mg_hcTable th, .mg_hcTable td { padding: .45rem .55rem; border-bottom: 1px solid var(--border-soft); font-size: .85rem; }
.mg_hcTable th { text-align: left; font-size: .7rem; color: var(--gold); text-transform: uppercase; letter-spacing: .08em; }
.mg_hcTable td { color: var(--text); }

/* Grids */
.mg_grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.mg_gridwide { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.mg_gridWide { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

/* Rank + officer cards */
.mg_grid .mg_card, .mg_gridwide .mg_card {
  padding: .9rem 1rem 1rem;
  margin: 0;
  border-radius: 12px;
  background: rgba(255,255,255,.015);
  border-color: var(--border-soft);
  box-shadow: none;
}
.mg_grid .mg_card:hover, .mg_gridwide .mg_card:hover { border-color: rgba(139,112,255,.3); }
.mg_role { font-size: .7rem; font-weight: 700; color: var(--gold); letter-spacing: .08em; text-transform: uppercase; margin-bottom: .4rem; }
.mg_officerBorder { padding: .35rem 0 .5rem; border-left: 2px solid rgba(139,112,255,.4); padding-left: 1rem; }
.mg_officerNameLine { font-weight: 700; color: var(--text); font-size: .98rem; }
.mg_officerRace { color: var(--muted); font-size: .82rem; }
.mg_officerDetails { color: var(--muted); line-height: 1.55; padding-left: 1rem; }
.mg_officerDetails b { color: var(--gold); font-weight: 700; }

.mg_coin { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-left: .2rem; }
.mg_roles_tbodyCost { white-space: nowrap; color: var(--gold-hi); font-weight: 600; }

/* Structure & Circles rank card internals */
.mg_rankDues {
  color: var(--gold-hi); font-weight: 600;
  padding-bottom: .4rem; margin-bottom: .5rem;
  border-bottom: 1px dashed var(--border-soft);
  cursor: default;
}
.mg_privList {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: .15rem;
}
.mg_privList li {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.45;
  cursor: help;
  transition: color .12s ease;
}
.mg_privList li:hover { color: var(--text); }
.mg_privList li::before {
  content: '\2022';
  color: var(--faint);
  margin-right: .5rem;
}

.mg_quests { margin: 0; padding-left: 1.2rem; color: var(--text); }
.mg_quests li { margin: .4rem 0; line-height: 1.55; font-size: .88rem; }

.mg_err { color: #ff9ba8; font-size: .82rem; padding: .6rem .9rem; border: 1px solid rgba(233,69,96,.35); background: rgba(233,69,96,.05); border-radius: 10px; }

/* Toast */
.mg-toast-host { position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 99999; display: flex; flex-direction: column; gap: .5rem; pointer-events: none; max-width: calc(100vw - 32px); }
.mg-toast { display: flex; align-items: center; gap: .6rem; padding: .7rem 1.05rem; border-radius: 10px; background: linear-gradient(180deg, rgba(26,26,45,.97), rgba(19,19,33,.97)); border: 1px solid var(--border); color: var(--text); font-size: .86rem; box-shadow: 0 10px 28px rgba(0,0,0,.5); pointer-events: auto; animation: mg-toast-in .22s ease-out; max-width: 440px; }
.mg-toast i { font-size: .9rem; flex-shrink: 0; }
.mg-toast.is-info i { color: var(--violet); }
.mg-toast.is-warn { border-color: rgba(232,160,80,.5); }
.mg-toast.is-warn i { color: #e8a050; }
.mg-toast.is-error { border-color: rgba(233,69,96,.55); }
.mg-toast.is-error i { color: #e94560; }
.mg-toast.is-out { opacity: 0; transform: translateY(-6px); transition: all .2s ease-in; }
@keyframes mg-toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 720px) {
  .mg-head { align-items: stretch; }
  .mg_identity { flex-direction: column; }
  .mg_label { width: 140px; }
}

/* Print */
@media print {
  body { background: #fff !important; color: #1b1b20; }
  .topbar, .footer, .mg-head-actions, .page-back, .mg-controls, .heraldry_reroll, .mg-toast-host { display: none !important; }
  .mg_card { background: #fff; border-color: #ccc; box-shadow: none; color: #1b1b20; }
  .mg_guildTitle, .mg_title, .mg_varText, .mg_role, .mg_label, .mg_h2, .mg_h3, .mg_structureTitle { color: #1b1b20 !important; -webkit-text-fill-color: #1b1b20 !important; background: none !important; }
  .mg_data, .mg_officerDetails, .mg_quests li { color: #2a2a30 !important; }
  .mg_grid .mg_card, .mg_gridwide .mg_card { border: 1px solid #ccc; }
}
