/*
  Character cards as D&D-style stat blocks (profile.html).

  A dark vellum panel with a double frame, small-caps name over an ember rule,
  an AC / HP / XP line, a six-ability table with modifiers on tinted bands, and
  an "Actions" section whose buttons are proper tiles (icon roundel, title,
  one-line description, cost). Click effects live here too: a ripple, a burst of
  sparks in the action's colour, and a ring that pulses out of the card.
  js/profile.js (renderCharCard / fx) supplies the markup and the sparks.
*/

.profile-shell .char-grid { gap: 22px; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); }

.profile-shell .char-card.sheet {
  --fx: var(--ghost);                       /* accent of the last-clicked action */
  --rule: #a8452d;                          /* the stat-block red-brown */
  position: relative;
  padding: 22px 24px 18px;
  border: 1px solid #6e5330;
  border-radius: 3px;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(168,69,45,.10), transparent 18rem),
    radial-gradient(ellipse at 0% 100%, rgba(215,174,88,.06), transparent 16rem),
    repeating-linear-gradient(0deg, rgba(255,240,210,.012) 0 2px, transparent 2px 4px),
    linear-gradient(180deg, #211b13, #17130d);
  box-shadow: inset 0 0 0 3px #17130d, inset 0 0 0 4px rgba(190,150,80,.32), 0 14px 34px rgba(0,0,0,.5);
  transition: border-color .2s, box-shadow .2s, transform .2s;
  container-type: inline-size;          /* lets the action tiles react to the CARD's width, not the window's */
}
/* little brass corner notches, like the framed blocks on a monster page */
.sheet::before, .sheet::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border: 1px solid rgba(215,174,88,.55); opacity: .8;
}
.sheet::before { top: 7px; left: 7px; border-right: 0; border-bottom: 0; }
.sheet::after { bottom: 7px; right: 7px; border-left: 0; border-top: 0; }
.profile-shell .char-card.sheet:hover { border-color: #8d6b3a; }
.profile-shell .char-card.sheet.selected {
  border-color: var(--good);
  box-shadow: inset 0 0 0 3px #17130d, inset 0 0 0 4px rgba(145,170,114,.5), 0 0 0 1px var(--good), 0 14px 34px rgba(0,0,0,.5);
}

/* ---- header ---- */
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.sheet .char-name {
  display: block; margin: 0; font: 700 1.45rem/1.1 var(--font-display); letter-spacing: .035em;
  font-variant: small-caps; color: #e9c98f; text-shadow: 0 1px 0 rgba(0,0,0,.6);
}
.sheet-sub { margin: 5px 0 0; font: italic 400 .95rem/1.3 var(--font-body); color: var(--ink-dim); }
.sheet .char-level {
  flex: none; margin-top: 2px; padding: 4px 11px; border-radius: 3px; border: 1px solid rgba(215,174,88,.5);
  background: linear-gradient(180deg, rgba(215,174,88,.18), rgba(215,174,88,.05));
  font: 600 .72rem/1 var(--font-display); letter-spacing: .12em; color: var(--ghost); text-transform: uppercase;
}
.sheet-rule { height: 3px; margin: 12px 0 10px; background: linear-gradient(90deg, var(--rule), #c9794a 55%, transparent); border-radius: 2px; }
.sheet-class {
  display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 12px; padding: 6px 10px;
  background: rgba(190,150,80,.10); border-left: 3px solid var(--rule); font-size: .84rem; color: var(--ink-bone);
}
.sheet-class b { color: #d8765a; font-variant: small-caps; letter-spacing: .04em; font-weight: 700; }

/* ---- vitals: AC / HP / XP ---- */
.sheet-vitals { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0 0 12px; }
.sheet-vitals > div { display: flex; gap: 7px; align-items: baseline; }
.sheet-vitals dt { margin: 0; font: 700 .76rem/1 var(--font-ui); letter-spacing: .08em; color: #d8765a; font-variant: small-caps; text-transform: lowercase; }
.sheet-vitals dd { margin: 0; font: 500 .95rem/1 var(--font-mono); color: var(--ink-bone); }
.sheet-vitals small { color: var(--ink-faint); font-size: .72rem; }

/* ---- abilities ---- */
.sheet-abilities {
  display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 4px;
  border-top: 1px solid rgba(168,69,45,.55); border-bottom: 1px solid rgba(168,69,45,.55);
}
.sheet-abilities .ab {
  display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 8px; padding: 7px 10px;
  border-right: 1px solid rgba(255,255,255,.05);
}
.sheet-abilities .ab:nth-child(3n) { border-right: 0; }
.sheet-abilities .ab:nth-child(-n+3) { background: rgba(150,175,140,.11); }
.sheet-abilities .ab:nth-child(n+4) { background: rgba(150,175,140,.04); }
.ab-k { font: 700 .74rem/1 var(--font-ui); letter-spacing: .08em; color: #d8765a; font-variant: small-caps; text-transform: lowercase; }
.ab-v { font: 500 1rem/1 var(--font-mono); color: var(--ink-bone); text-align: right; }
.ab-m { min-width: 2.2ch; font: 600 .86rem/1 var(--font-mono); color: var(--ghost); text-align: right; }
.ab-m.neg { color: #b98d78; }

/* ---- section heading ---- */
.sheet-h {
  display: flex; align-items: center; gap: 10px; margin: 16px 0 10px; padding: 0 0 5px;
  font: 700 1.05rem/1 var(--font-display); letter-spacing: .06em; font-variant: small-caps; color: #e0a27d;
  border-bottom: 2px solid var(--rule);
}
.sheet-h::after { content: ""; flex: 1; }

/* ---- action tiles ---- */
.sheet-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.act {
  --c: var(--ghost);
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 11px;
  min-height: 58px; padding: 9px 12px 9px 10px; text-align: left; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--c) 38%, transparent); border-radius: 3px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 11%, transparent), rgba(0,0,0,.18) 70%), rgba(15,12,8,.55);
  color: var(--ink-bone); font: inherit;
  transition: transform .15s cubic-bezier(.2,.8,.2,1), border-color .15s, box-shadow .2s, background .2s;
}
.act:hover, .act:focus-visible {
  outline: none; transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--c) 80%, white 8%);
  box-shadow: 0 8px 18px rgba(0,0,0,.45), 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent), 0 0 22px color-mix(in srgb, var(--c) 22%, transparent);
}
.act:active { transform: translateY(1px) scale(.975); box-shadow: inset 0 3px 10px rgba(0,0,0,.55); transition-duration: .05s; }
.act-ic {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--c) 70%, transparent); color: var(--c);
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 28%, transparent), rgba(0,0,0,.35));
  transition: transform .25s cubic-bezier(.3,1.6,.5,1), box-shadow .25s;
}
.act:hover .act-ic { transform: rotate(-8deg) scale(1.08); box-shadow: 0 0 14px color-mix(in srgb, var(--c) 50%, transparent); }
.act-ic svg { width: 19px; height: 19px; }
.act-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.act-txt b { font: 600 .86rem/1.2 var(--font-ui); color: var(--ink-bone); }
.act-txt small { font: 400 .72rem/1.25 var(--font-ui); color: var(--ink-faint); }
.act-cost {
  align-self: center; padding: 3px 8px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  font: 600 .72rem/1 var(--font-mono); color: var(--c); background: rgba(0,0,0,.28); white-space: nowrap;
}
.act-open { align-self: center; color: var(--c); font-size: .8rem; transition: transform .25s; }
.act[aria-expanded="true"] .act-open { transform: rotate(180deg); }
.act[aria-expanded="true"] {
  border-color: var(--c); background: linear-gradient(135deg, color-mix(in srgb, var(--c) 22%, transparent), rgba(0,0,0,.2) 75%), rgba(15,12,8,.6);
}
.act-loot { --c: #91aa72; }
.act-relevel { --c: #d7ae58; }
.act-forge { --c: #e08a3c; }
.act-shop { --c: #6aa6e6; }
.act:disabled { cursor: not-allowed; filter: grayscale(.85); opacity: .5; transform: none; box-shadow: none; }
.act:disabled:hover .act-ic { transform: none; box-shadow: none; }

/* ---- footer ---- */
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.sheet-foot .char-pending { margin: 0; flex: 1; font: italic .85rem/1.3 var(--font-body); color: var(--ink-faint); }
.profile-shell .sheet .char-delete {
  display: inline-flex; align-items: center; gap: 6px; width: auto; height: 28px; padding: 0 10px; flex: none;
  font: 600 .68rem/1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase;
}
.profile-shell .sheet .char-delete svg { width: 14px; height: 14px; }

/* ---- expanded panels ---- */
.profile-shell .char-card.sheet.forge-open { grid-column: 1 / -1; }
.sheet .forge-slot { margin-top: 16px; }
.sheet .forge-slot.unfurl { animation: sheet-unfurl .45s cubic-bezier(.2,.8,.2,1) both; transform-origin: top; }
@keyframes sheet-unfurl { from { opacity: 0; transform: translateY(-10px) scaleY(.94); } to { opacity: 1; transform: none; } }

/* ---- click effects ---- */
.fx-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 5; border-radius: inherit; }
.spark {
  position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--fx); opacity: 0;
  box-shadow: 0 0 8px 1px var(--fx);
  animation: spark-fly .65s cubic-bezier(.1,.7,.3,1) forwards;
}
@keyframes spark-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(1.2); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.2); }
}
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none; z-index: -1;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 55%, transparent), transparent 70%);
  transform: scale(0); opacity: .9; animation: ripple-out .6s ease-out forwards;
}
@keyframes ripple-out { to { transform: scale(1); opacity: 0; } }
.sheet.pulse::before { animation: none; }
.sheet .fx-ring {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 4;
  box-shadow: 0 0 0 0 var(--fx), inset 0 0 0 0 var(--fx); opacity: 0; animation: ring-pulse .7s ease-out;
}
@keyframes ring-pulse {
  0% { opacity: .9; box-shadow: 0 0 0 0 var(--fx), inset 0 0 0 0 transparent; }
  60% { opacity: .5; box-shadow: 0 0 0 10px transparent, inset 0 0 26px 2px var(--fx); }
  100% { opacity: 0; box-shadow: 0 0 0 16px transparent, inset 0 0 0 0 transparent; }
}
.fx-toast {
  position: absolute; left: 50%; bottom: 46%; z-index: 6; padding: 6px 14px; transform: translateX(-50%);
  border: 1px solid var(--fx); border-radius: 3px; background: rgba(15,12,8,.92); color: var(--fx);
  font: 700 .8rem/1 var(--font-display); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap;
  box-shadow: 0 0 22px color-mix(in srgb, var(--fx) 40%, transparent); pointer-events: none;
  animation: toast-rise 1.5s ease-out forwards;
}
@keyframes toast-rise {
  0% { opacity: 0; transform: translate(-50%, 14px) scale(.9); }
  14% { opacity: 1; transform: translate(-50%, 0) scale(1.04); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -34px) scale(1); }
}

@container (max-width: 470px) {
  .sheet-actions { grid-template-columns: minmax(0, 1fr); }
  .act { min-height: 54px; }
}
@media (max-width: 520px) {
  .sheet-actions { grid-template-columns: minmax(0, 1fr); }
  .profile-shell .char-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-shell .char-card.sheet { padding: 18px 16px 14px; }
  .sheet-abilities .ab { padding: 6px 6px; gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .spark, .ripple, .fx-ring, .fx-toast, .sheet .forge-slot.unfurl { animation: none !important; display: none; }
  .act, .act-ic { transition: none; }
  .act:hover { transform: none; }
}

/* ---------- Tradeskill Book (js/tradebook.js) ---------- */
.act-book { --c: #b58ae0; }
.act-estates { --c: #f2f2f2; }
.act-inventory { --c: #d9b36a; }
.act-sellswords { --c: #46d6a8; }
.book {
  padding: 20px 22px 22px; border: 1px solid rgba(165,125,204,.42);
  background: radial-gradient(ellipse at 85% 0%, rgba(165,125,204,.12), transparent 24rem),
              repeating-linear-gradient(0deg, rgba(255,240,210,.012) 0 2px, transparent 2px 4px),
              linear-gradient(180deg, rgba(36,26,48,.55), rgba(17,14,10,.85));
  box-shadow: inset 0 0 0 3px rgba(17,14,10,.9), inset 0 0 0 4px rgba(165,125,204,.22);
}
.book .forge-intro h3 { color: #d3b8f0; }
.book-filter { margin: 6px 0 18px; font-size: .72rem; padding: 6px 12px; }
.book-groups { columns: 2 340px; column-gap: 26px; }
.book-group { break-inside: avoid; margin: 0 0 18px; }
.book-group h4 {
  margin: 0 0 8px; padding-bottom: 4px; font: 700 .95rem/1 var(--font-display); letter-spacing: .06em;
  font-variant: small-caps; color: #c9a6ea; border-bottom: 2px solid rgba(165,125,204,.55);
}
.skill { margin-bottom: 4px; border: 1px solid transparent; border-radius: 3px; transition: background .2s, border-color .2s; }
.skill:hover { background: rgba(165,125,204,.06); }
.skill.is-open { background: rgba(165,125,204,.09); border-color: rgba(165,125,204,.3); }
.skill-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto 18px; grid-template-areas: "n t p c" "b b b b";
  align-items: baseline; gap: 2px 10px; width: 100%; padding: 7px 8px 6px; text-align: left;
  background: none; border: 0; color: inherit; font: inherit; cursor: pointer;
}
.skill-name { grid-area: n; font: 600 .86rem/1.2 var(--font-ui); color: var(--ink-bone); }
.skill-tier { grid-area: t; font: 600 .62rem/1 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.skill-pct { grid-area: p; min-width: 4.6ch; text-align: right; font: 600 .82rem/1 var(--font-mono); color: var(--ghost); }
.skill-chev { grid-area: c; color: var(--ink-faint); transition: transform .25s; }
.skill.is-open .skill-chev { transform: rotate(180deg); }
.skill-bar { grid-area: b; position: relative; display: block; height: 7px; margin-top: 4px; border-radius: 4px; background: rgba(255,255,255,.07); }
.skill-bar .fill {
  display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #6d4f93, #b58ae0);
  box-shadow: 0 0 8px rgba(181,138,224,.45); animation: bar-grow .7s cubic-bezier(.2,.8,.2,1) both; transform-origin: left;
}
@keyframes bar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.skill-bar .tick { position: absolute; top: -2px; width: 2px; height: 11px; margin-left: -1px; background: rgba(215,174,88,.55); border-radius: 1px; }
.skill-bar .tick.got { background: var(--good); }
.skill-bar .tick.perk { background: rgba(165,125,204,.7); height: 7px; top: 0; }
.skill.t0 .skill-pct { color: var(--ink-faint); }
.skill.t1 .skill-tier { color: #b8a77f; } .skill.t2 .skill-tier { color: #9fc48a; } .skill.t3 .skill-tier { color: #6aa6e6; }
.skill.t4 .skill-tier { color: #b58ae0; } .skill.t5 .skill-tier { color: #e08a3c; }
.skill.t6 .skill-tier { color: #ffd27a; text-shadow: 0 0 8px rgba(255,210,122,.6); }
.skill.t4 .fill { background: linear-gradient(90deg, #6d4f93, #d3a3ff); }
.skill.t5 .fill { background: linear-gradient(90deg, #8a4a1c, #ffb347); }
.skill.t6 .fill { background: linear-gradient(90deg, #b8860b, #ffe08a); box-shadow: 0 0 12px rgba(255,210,122,.7); }
.skill-next { display: block; padding: 0 8px 6px; font-size: .72rem; color: var(--ink-faint); }
.skill-next b { color: var(--ghost); font-family: var(--font-mono); font-weight: 600; }
.skill-next.done { color: var(--good); }
.skill-detail { padding: 2px 10px 10px; animation: sheet-unfurl .3s ease both; }
.skill-blurb { margin: 0 0 8px; font: italic .9rem/1.35 var(--font-body); color: var(--ink-dim); }
.skill-ms { list-style: none; margin: 0; padding: 0; }
.skill-ms li { display: grid; grid-template-columns: 4.4ch 1.4em minmax(0, 1fr); gap: 6px; align-items: baseline; padding: 3px 0; border-top: 1px solid var(--line); font-size: .78rem; }
.skill-ms .ms-pct { font: 600 .74rem var(--font-mono); color: var(--ghost); text-align: right; }
.skill-ms li.open .ms-text { color: var(--ink-bone); }
.skill-ms li.locked { opacity: .62; }
.skill-ms li.perk .ms-text em { font-style: normal; font-size: .65rem; letter-spacing: .08em; text-transform: uppercase; color: #b58ae0; }
.skill-none { margin: 4px 0 0; font-size: .76rem; color: var(--ink-faint); }
@media (prefers-reduced-motion: reduce) { .skill-bar .fill, .skill-detail { animation: none; } }

/* Offer-as-a-service switch under each trained skill */
.svc-toggle { display: inline-flex; align-items: center; gap: 8px; margin: 0 8px 7px; cursor: pointer; font: 600 .72rem/1 var(--font-ui); color: var(--ink-faint); user-select: none; }
.svc-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.svc-track { position: relative; width: 30px; height: 16px; border-radius: 999px; background: #1b2024; border: 1px solid var(--line-strong); transition: background .15s, border-color .15s; }
.svc-track i { position: absolute; top: 2px; left: 2px; width: 10px; height: 10px; border-radius: 50%; background: #6c7a82; transition: transform .15s, background .15s; }
.svc-toggle.on { color: #ffd08a; }
.svc-toggle.on .svc-track { background: rgba(224,138,60,.28); border-color: #e08a3c; }
.svc-toggle.on .svc-track i { transform: translateX(14px); background: #f0a24e; }
.svc-toggle input:focus-visible + .svc-track { outline: 2px solid #e08a3c; outline-offset: 2px; }
.svc-toggle input:disabled ~ * { opacity: .5; }
.svc-intro { margin: 8px 0; padding: 8px 10px; border: 1px dashed rgba(224,138,60,.4); border-radius: 3px; font-size: .78rem; color: var(--ink-dim); line-height: 1.4; }
.svc-intro a { color: #f0a24e; }
.svc-err { color: #f0a286; }

/* Pin to top */
.sheet-class { align-items: center; }
.char-pin { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: transparent; color: var(--ink-faint); font: 600 .68rem/1 var(--font-ui); letter-spacing: .04em; cursor: pointer; transition: color .15s, border-color .15s, background .15s; }
.char-pin svg { width: 13px; height: 13px; }
.char-pin:hover { color: #ffd08a; border-color: #e08a3c; }
.char-pin.on { color: #1a0e05; background: linear-gradient(180deg, #e08a3c, #8a4a1c); border-color: #e08a3c; }
.char-pin.on svg { fill: currentColor; }

/* unpinned characters folded away behind a bar while some are pinned (js/profile.js) */
.char-grid .char-folded { display: none !important; }
.char-fold { grid-column: 1 / -1; width: 100%; display: flex; align-items: center; gap: .5rem; justify-content: center; padding: .6rem 1rem; margin: .2rem 0;
  border: 1px dashed rgba(217,179,106,.45); border-radius: 8px; background: rgba(217,179,106,.06); color: #e9c98f; cursor: pointer; font: inherit; letter-spacing: .04em; }
.char-fold:hover { background: rgba(217,179,106,.14); border-color: #d9b36a; }
.char-fold .chev { font-size: .9em; }
