/* Vortex Legends damage calculator — dark, dense, built for long comparison sessions. */

:root {
  --bg:        oklch(0.17 0.012 240);
  --surface:   oklch(0.22 0.013 240);
  --surface-2: oklch(0.26 0.014 240);
  --line:      oklch(0.34 0.014 240);
  --line-soft: oklch(0.29 0.013 240);

  --ink:       oklch(0.95 0.005 240);
  --ink-2:     oklch(0.80 0.010 240);
  --ink-3:     oklch(0.66 0.012 240);

  --accent:    oklch(0.78 0.135 168);
  --accent-dk: oklch(0.45 0.085 168);
  --warn:      oklch(0.76 0.150 55);
  --danger:    oklch(0.70 0.170 25);

  --field:     oklch(0.30 0.015 240);
  --field-hi:  oklch(0.35 0.018 240);

  --r:  6px;
  --r-lg: 10px;
  --pad: 14px;

  --z-overlay: 5000;
  --z-modal:   6000;
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  padding: 28px 20px 56px;
  max-width: 1320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

table { width: 100%; border-collapse: collapse; }
td { padding: 2px 6px; vertical-align: middle; }

/* ---------- Panel headers ---------- */
/* Were gradient banners with a 7-layer white text-shadow. Now quiet rules that
   separate sections without competing with the data underneath. */
h1, h2, h3 {
  /* Some section headers carry controls inline (the Calculate button lives inside an h3),
     so these are flex rows, not plain text. */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 0 0;
  padding: 0 0 9px;
  border-bottom: 1px solid var(--line);
  background: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-variant: normal;
  line-height: 1.3;
  color: var(--accent);
  text-shadow: none;
  border-radius: 0;
  height: auto;
}
h1 {
  margin-top: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--ink);
  padding-bottom: 0;
  border-bottom: 0;
}
h1 img, h3 img { display: none; }

/* ---------- Intro + options bar ---------- */
.intro { margin-bottom: 16px; }
.lede { margin: 4px 0 2px; color: var(--ink-2); font-size: 14px; font-weight: 400; }
.lede strong { color: var(--ink); font-weight: 600; }
.sub  { margin: 0; color: var(--ink-3); font-size: 12px; font-weight: 400; }

.optbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface-2);
}
.optbar-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-right: 2px;
}
.opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 120ms cubic-bezier(0.22, 1, 0.36, 1);
}
.opt:hover { color: var(--ink); }
.opt.off { color: var(--ink-3); opacity: 0.55; cursor: not-allowed; text-decoration: line-through; }
.opt input { margin: 0; }

/* ---------- Surfaces ---------- */
.main {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: var(--pad);
  margin-top: 10px;
  overflow-x: auto;   /* only the panel scrolls, never the page */
}

/* The old rule was `div {overflow:auto}` — every nested div grew its own
   scrollbar, which is what made the layout look broken. */
.main div { overflow: visible; }

/* Applied to <td> inside data tables, so it has to read as a header ROW —
   borders + radius here turn every section into a floating box. */
.subheader {
  padding: 6px 10px;
  margin: 0;
  background: var(--surface-2);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.6;
}
.subheader.point:hover { background: var(--field-hi); color: var(--accent); text-decoration: none; }
.subheader div { font-weight: 400; letter-spacing: 0; text-transform: none; }
.subheader input {
  border: 1px solid var(--line);
  margin: 0 4px;
  padding: 1px 4px;
  background: var(--field);
  color: var(--ink);
  text-align: center;
  border-radius: 4px;
}
.subheader select { margin: 0; letter-spacing: 0; }

/* ---------- Tables ---------- */
.tborder, .tborderA {
  border: 1px solid var(--line-soft);
  border-collapse: collapse;
  border-radius: var(--r);
  overflow: hidden;
  background: none;   /* tinting the whole table makes empty rows read as hollow boxes */
}
.tborderA { width: auto; }
.tborder td, .tborderA td { border: 0; }
.tequip td { padding: 1px 4px; vertical-align: top; }

/* ---------- Equipment grid ----------
   Every row here is a single <td> holding a label plus 2-4 selects sized to
   their own content, so no two rows lined up. Force a shared grid and place
   each select by name; bare text nodes auto-place into the free column. */
/* table-layout:fixed is required: without a definite cell width the table sizes
   each cell from its own content, so the fr units resolve differently per row. */
.eq-weapon, .eq-armor { table-layout: fixed; width: 100%; }

.eq-weapon > tbody > tr > td {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  gap: 3px 8px;
  padding: 2px 4px;
}
.eq-weapon > tbody > tr > td > select { grid-column: 2; width: 100%; min-width: 0; }

.eq-armor > tbody > tr > td {
  display: grid;
  /* the 4th track is fixed, not auto: an auto track collapses to 0 on rows that
     have no enchant select, which changes how the two 1fr tracks resolve */
  grid-template-columns: 56px minmax(0, 1fr) minmax(0, 1fr) 92px;
  align-items: center;
  gap: 3px 6px;
  padding: 2px 4px;
}
.eq-armor > tbody > tr > td > select { grid-column: 2; width: 100%; min-width: 0; }
.eq-armor > tbody > tr > td > select[name$="_DEF_PLUS"]  { grid-column: 1; }
.eq-armor > tbody > tr > td > select[name$="_card"]      { grid-column: 3; }
.eq-armor > tbody > tr > td > select[name="A_HSE_HEAD1"] { grid-column: 3; }
.eq-armor > tbody > tr > td > select[name="A_HSE"]       { grid-column: 4; }

/* Simulator settings: these were bare label text + select + <br>, so every
   dropdown started at a different x. */
.setting {
  display: grid;
  grid-template-columns: 260px minmax(0, 340px) auto;
  align-items: center;
  gap: 4px 10px;
  margin: 3px 0;
}
.setting > select { width: 100%; }
.setting-label { color: var(--ink-2); }
.setting .note { color: var(--ink-3); font-size: 12px; }

.tag-scroll { color: var(--warn); }
.tag-leaf   { color: var(--accent); }

/* Weapon read-out strip (ATK / Weapon Lv / Req. Lv / Weight) — these carried a
   hard-coded pale blue that was unreadable on a dark surface. */
#ITEM1, #ITEM2, #ITEM3, #ITEM4 {
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
#ITEM_DATA, #ITEM_W_LV, #ITEM_LV, #ITEM_WAIT { color: var(--ink); font-weight: 600; }

.data { border-right: 1px dotted var(--line); padding-right: 6px; font-weight: 400; color: var(--ink-2); }
.dotB { border-bottom: 1px dotted var(--line); padding-bottom: 3px; }
.title {
  text-align: center;
  font-weight: 650;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
}
.center { text-align: center; }
.right  { float: right; }

/* ---------- Form controls ---------- */
input, select, button {
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
select {
  border: 1px solid var(--line);
  margin: 1px;
  padding: 2px 22px 2px 7px;
  background: var(--field)
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23A8B0BA' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 7px center;
  border-radius: 5px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  max-width: 100%;
  transition: border-color 120ms cubic-bezier(0.22, 1, 0.36, 1),
              background-color 120ms cubic-bezier(0.22, 1, 0.36, 1);
}
select:hover { background-color: var(--field-hi); border-color: var(--ink-3); }
select option { background: var(--surface-2); color: var(--ink); }

input[type="text"], input:not([type]) {
  margin: 2px;
  padding: 2px 6px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 5px;
}
input[type="text"]:hover, input:not([type]):hover { border-color: var(--ink-3); }

input[type="button"], input[type="submit"], button {
  padding: 4px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-weight: 550;
  cursor: pointer;
  transition: background-color 120ms cubic-bezier(0.22, 1, 0.36, 1),
              border-color 120ms cubic-bezier(0.22, 1, 0.36, 1);
}
input[type="button"]:hover, input[type="submit"]:hover, button:hover {
  background: var(--field-hi);
  border-color: var(--accent-dk);
}
input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

:where(input, select, button):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.thin select { height: auto; padding-top: 1px; padding-bottom: 1px; }
.manual input { border: 1px solid var(--line); width: 44px; }

/* ---------- Links & misc ---------- */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.main a { color: var(--accent); }
.main a:hover { font-weight: inherit; text-decoration: underline; }

p { color: var(--ink-2); font-weight: 400; }

.point { cursor: pointer; color: var(--ink-3); }
.point:hover { color: var(--accent); text-decoration: underline; }

.links {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 16px;
  text-align: center;
  color: var(--ink-2);
}
.links a { color: var(--accent); }
.links a:hover { color: var(--ink); }

#foot { line-height: 1.9; text-align: right; color: var(--ink-3); margin-top: 22px; }

#calcoptions {
  background: var(--surface-2);
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  position: fixed;
  top: 0; left: 0;
  padding: 8px;
  color: var(--ink);
  z-index: 10;
}
#calcoptions p { color: var(--accent); text-align: center; }

/* ---------- Modal ---------- */
.p_overlay {
  background: oklch(0.12 0.01 240 / 0.72);
  width: 100%; height: 100%;
  position: fixed; top: 0; left: 0;
  z-index: var(--z-overlay);
  display: block;
}
.p_box {
  background: var(--surface);
  border: 1px solid var(--line);
  z-index: var(--z-modal);
  display: block;
  width: 320px;
  position: relative;
  margin: 100px auto 0;
  min-height: 200px;
  border-radius: var(--r-lg);
  box-shadow: 0 18px 48px oklch(0 0 0 / 0.55);
  padding: 16px;
}
.p_close {
  position: absolute;
  right: 10px; top: 8px;
  text-indent: -9999px;
  background: url(closebtnicon.png);
  width: 18px; height: 19px;
  cursor: pointer;
}

/* ---------- Skill tree ---------- */
#SkillTreeBox, #SkillStateBox {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  margin-bottom: 10px;
  overflow-x: auto;
}
#SkillStateBox .stst { border-top: 0; }
.sthd {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 600;
}
.sthd b { color: var(--ink); }
.sthd .stneg { color: var(--danger); }
.sttb {
  display: flex;
  gap: 4px;
  padding: 6px 8px 0;
}
.sttb button {
  background: var(--surface);
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--r) var(--r) 0 0;
  padding: 4px 14px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.sttb button:hover { color: var(--ink); }
.sttb button.on {
  background: var(--surface-2);
  color: var(--accent);
  border-color: var(--accent-dk);
}
.sthd .stick {
  margin-left: auto;
  margin-right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
}
.sthd .stick:hover { color: var(--ink-2); }
.sthd .stick input { margin: 0; }
.sthd .stunlock {
  margin-right: 16px;
  font: inherit;
  font-size: 12px;
  font-weight: 400;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--accent-dk);
  border-radius: var(--r);
  padding: 3px 12px;
  cursor: pointer;
  touch-action: manipulation;
}
.sthd .stunlock:hover { background: var(--accent-dk); color: var(--ink); }
.stbody { display: flex; align-items: stretch; gap: 10px; }
.stbody > .stg { flex: 0 0 auto; }
/* The grid alone sets the height. The panel is taken out of the flow and scrolls inside its
   wrapper, so hovering a skill with a long description no longer resizes the whole box. */
.stiwrap {
  position: relative;
  flex: 1 1 260px;
  min-width: 240px;
  min-height: 230px;
}
/* `.main div { overflow: visible }` above outranks a lone `.stinfo`, so this one needs
   the extra class to actually clip. Without it the text spills out of the panel. */
.main .stinfo {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.stinfo {
  position: absolute;
  top: 8px; right: 8px; bottom: 8px; left: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-2);
}
.stinfo p { margin: 7px 0 0; }
.stinfo em { color: var(--accent); font-style: normal; font-weight: 600; }
.stinfo i { color: var(--ink); font-style: normal; }
.stinfo kbd {
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--field);
  color: var(--ink);
  font-size: 11px;
}
.stimsg { color: var(--ink-3); }
.stih { color: var(--ink); font-weight: 650; font-size: 13px; }
.stih span { color: var(--ink-3); font-weight: 400; font-size: 12px; }
.stit {
  color: var(--ink-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1px;
}
.stin { margin-top: 5px; color: var(--ink-2); }
.stin b { color: var(--ink-3); font-weight: 400; }
.stif {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--line-soft);
  color: var(--ink);
}
.stixf { color: var(--ink-3); }
.stg {
  display: grid;
  grid-template-columns: repeat(7, 96px);
  gap: 2px;
  padding: 8px;
  min-width: 690px;
}
.ste {
  height: 78px;
  border: 1px dashed var(--line-soft);
  border-radius: var(--r);
  opacity: 0.45;
}
.stc {
  height: 78px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  padding: 2px;
  text-align: center;
  overflow: hidden;
  cursor: pointer;   /* the cell body selects the skill for the info panel */
}
.stc .stn {
  font-size: 10px;
  line-height: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stc img {
  width: 24px; height: 24px;
  image-rendering: pixelated;
  margin: 1px 0;
}
.stc .stv {
  font-size: 11px;
  color: var(--ink);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 6px;
}
.stc .stv b {
  cursor: pointer;
  color: var(--accent);
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  font-size: 15px;
  line-height: 1;
  touch-action: manipulation;   /* no 300ms tap delay / double-tap zoom on mobile */
}
.stc .stv b:hover { color: var(--ink); border-color: var(--accent-dk); }
.stc .stv b:active { background: var(--accent-dk); color: var(--ink); }
.stc.st0 { background: var(--surface); }
.stc.st0 img { filter: grayscale(1); opacity: 0.5; }
.stc.st0 .stn { color: var(--ink-3); }
.stc.stsel {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-dk);
}
.stc.stj { opacity: 0.45; }
.stc.stj .stv b { pointer-events: none; color: var(--ink-3); }
.stc.stf { border-color: var(--accent-dk); }
.stc.stf .stn { color: var(--accent); }
.stst {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}
.stst > span { color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.stst label { color: var(--ink-2); }
.stft { padding: 6px 10px; border-top: 1px solid var(--line-soft); }

/* ---------- Monster Combat Simulator ----------
   Layout-only rework: the section shared the app classes but kept a float-based
   layout with the Calculate button flung to a 14% inline margin. Scoped to .mcs
   so nothing else moves; no IDs or handlers changed. */
/* input.mcs-calc, not .mcs-calc: the base input[type="button"] rule ties on
   specificity, so the class alone would lose the background. */
input.mcs-calc {
  padding: 7px 24px;
  background: var(--accent);
  color: oklch(0.20 0.03 168);
  border: 1px solid var(--accent);
  border-radius: var(--r);
  font-weight: 650;
  letter-spacing: 0.02em;
}
input.mcs-calc:hover { background: var(--accent-dk); border-color: var(--accent-dk); color: var(--ink); }

.mcs-opts {
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  background: var(--surface-2);
}
.mcs-opts .setting { margin: 5px 0; }
/* the Spell-scrolls / Yggdrasil toggle sits apart from the dropdowns */
.mcs-opts > div:last-child {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
  text-align: left !important;
  color: var(--ink-2);
}

/* two result columns; flex neutralizes the legacy inline float:left */
.mcs-cols {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 4px;
}
.mcs-cols > div,
.mcs-cols > table { flex: 1 1 360px; min-width: 300px; margin: 0 !important; }

/* tables become proper cards */
.mcs .tborderA {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.mcs .tborderA td { padding: 5px 11px; }
.mcs .tborderA tr:not(:first-child) td { border-top: 1px solid var(--line-soft); }
.mcs .tborderA .subheader { border-top: 0; }
.mcs .data { border-right: 0; color: var(--ink); }
.mcs .center { color: var(--ink-3); }

/* headline outputs pop in the accent */
.mcs #strID_0, .mcs #strID_1, .mcs #strID_2, .mcs #AveSecondATK,
.mcs #B_MinAtk, .mcs #B_AveAtk, .mcs #B_MaxAtk {
  color: var(--accent);
  font-weight: 650;
}

/* collapsibles below the columns: full width, drop the legacy inline float/width */
.mcs #MONSTER_KYOUKA,
.mcs #MONSTER_IJYOU,
.mcs #B_MANUAL { margin: 10px 0 0 !important; }
.mcs #MONSTER_KYOUKA,
.mcs #MONSTER_IJYOU { float: none !important; width: auto !important; }

@media (max-width: 600px) {
  .stg { grid-template-columns: repeat(7, 112px); min-width: 810px; }
  .stc { height: 90px; }               /* room for bigger tap targets */
  .stc .stv { gap: 8px; }
  .stc .stv b { min-width: 30px; min-height: 30px; font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
