/* guildle's styles, part 2 of 10 (cards.css). The adventurer card, and how worn it looks by rarity.
   The parts load in order (index.html) and later rules build on earlier ones. */

/* The adventurer card */
.card {
  --rc: var(--r-common);
  container-type: inline-size;
  position: relative; aspect-ratio: 5 / 7; width: 100%;
  background: linear-gradient(160deg, var(--card) 0%, var(--card-edge) 100%);
  color: var(--ink);
  border-radius: 3.7% / 2.64%;   /* proportional, so small cards are exact scaled copies */
  border: 1px solid rgba(0,0,0,.25);
  box-shadow: 0 12px 26px rgba(0,0,0,.4);
  padding: 6% 7% 5%;
  /* Fixed template: every section has the same share of the card at any size. */
  /* Percentages of the card's own height; container units don't apply to the card itself. */
  display: grid; grid-template-rows: 17% minmax(0, 1fr) 15.5% 8%; row-gap: 1.3%;
  overflow: hidden;
}
/* The rarity rim and edge wear, drawn inside the card so they scale with it. */
.card > .frame {
  position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
  box-shadow: inset 0 0 0 1.15cqw var(--rc), inset 0 0 0 1.7cqw var(--card), var(--edge);
}
/* faint worn diamond lattice on the card face */
.card { isolation: isolate; }
.card::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit;
  background-image:
    repeating-linear-gradient(45deg, rgba(90, 62, 30, .13) 0 1px, transparent 1px 30cqw),
    repeating-linear-gradient(-45deg, rgba(90, 62, 30, .13) 0 1px, transparent 1px 30cqw),
    repeating-linear-gradient(45deg, rgba(90, 62, 30, .07) 0 1px, transparent 1px 7.5cqw),
    repeating-linear-gradient(-45deg, rgba(90, 62, 30, .07) 0 1px, transparent 1px 7.5cqw);
  -webkit-mask-image: var(--wear); mask-image: var(--wear);
  -webkit-mask-size: 260px 260px; mask-size: 260px 260px;
}
.card.uncommon { --rc: var(--r-uncommon); }
.card.rare { --rc: var(--r-rare); }
.card.epic { --rc: var(--r-epic); }
.card.legendary { --rc: var(--r-legendary); }
.card.legendary::after, .card.epic::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.45) 45%, transparent 60%);
  background-size: 250% 100%; background-repeat: no-repeat; animation: sheen 4.5s ease-in-out infinite;
  mix-blend-mode: soft-light;
}
/* The band starts and ends fully off the card (its slant reaches further at the corners), so the loop never jumps. */
@keyframes sheen { 0% { background-position: 150% 0; } 60%, 100% { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) { .card::after { animation: none !important; } }

.corner { position: absolute; display: grid; justify-items: center; line-height: 1; font-variant-numeric: tabular-nums; }
.corner b { font: 800 9cqw/1 var(--sans); color: var(--rc); }
.corner i { font-style: normal; font: 700 3.6cqw/1 var(--sans); letter-spacing: .08em; color: var(--ink-soft); margin-top: 1cqw; }
.corner.tl { top: 5.5%; left: 6.5%; }


.c-head { text-align: center; padding-inline: 12%; overflow: hidden; display: grid; grid-template-rows: 9.4cqw; grid-auto-rows: auto; align-content: start; padding-top: var(--name-drop, 1.6cqw); }
.c-head > .c-name { align-self: center; white-space: nowrap; }
.c-head > .c-title { margin-top: 0; height: 7cqw; line-height: 7cqw; white-space: nowrap; } /* only there when the card has a title */
.c-title:empty::before, .c-title:empty::after { content: none; } /* no title: the slot stays, the dashes go */
.c-head > .c-sub { margin-top: .6cqw; }
.c-name { font: 400 var(--name-size, 8cqw)/1.05 var(--display); margin: 0; }
.c-title { font: italic 5.4cqw/1.1 var(--serif); color: var(--ink); margin-top: .8cqw; }
.c-title::before, .c-title::after { content: "\2014"; color: var(--tc, var(--rc)); margin-inline: 1.6cqw; font-style: normal; }
.c-perk-row { display: grid; align-content: center; }
.c-perk {
  display: grid; gap: .4cqw; text-align: center; padding: 1.2cqw 2.4cqw; border-radius: 1.6cqw;
  border: 1px dashed rgba(90, 62, 30, .55); background: rgba(244, 236, 218, .9); color: var(--ink-soft);
}
.c-perk .pk { font: 800 2.9cqw/1.1 var(--sans); letter-spacing: .1em; text-transform: uppercase; }
.c-perk .pt { font: italic 3.5cqw/1.15 var(--serif); color: var(--ink); opacity: .7; }
.c-perk.on { border: 1px solid #a8791e; background: linear-gradient(135deg, rgba(240, 207, 142, .55), rgba(201, 153, 74, .28)); color: #6a4708; box-shadow: 0 0 0 1px rgba(255, 244, 205, .6) inset; }
.c-perk.on .pt { opacity: 1; }
.t-name[data-tip] { cursor: help; border-radius: 3px; }
.t-name[data-tip]:hover { text-decoration: underline dotted 1px; text-underline-offset: 2px; }
.t-name[data-tip]:focus-visible { outline: 2px solid var(--tc); outline-offset: 2px; }
.tip {
  position: fixed; z-index: 30; pointer-events: none; transform: translate(-50%, calc(-100% - 10px));
  background: #1b120a; color: #f6ecd6; border: 1px solid #6b4f2a; border-radius: 6px; padding: 6px 10px;
  font: 700 .82rem/1.3 var(--sans); letter-spacing: .03em; text-align: center; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0,0,0,.45); animation: tipin .14s ease-out;
}
.tip::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; margin-left: -5px; background: #1b120a; border-right: 1px solid #6b4f2a; border-bottom: 1px solid #6b4f2a; transform: rotate(45deg); }
.tip .pp { display: block; font-weight: 500; font-size: .74rem; color: #cbb892; margin-top: 2px; white-space: normal; max-width: 220px; }
.tip.below { transform: translate(-50%, 10px); }
.tip.below::after { top: -6px; bottom: auto; transform: rotate(225deg); }
@keyframes tipin { from { opacity: 0; } to { opacity: 1; } }
.bar { display: flex; }
.bar .boon { background: #3f8a58 !important; }   /* from the title */
.bar .rboon { background: #b07a3a !important; }  /* from the race */
.stat.buffed .v { color: #2f6b45; }
.c-sub { font: 700 3.6cqw/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); margin-top: 1.4cqw; }

.c-art {
  position: relative; margin-inline: 4%; min-height: 0; border-radius: 1.6cqw;
  background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--rc) 28%, var(--card)) 0%, color-mix(in srgb, var(--rc) 55%, #3a2c1e) 100%);
  border: 1px solid color-mix(in srgb, var(--rc) 60%, #000);
  display: grid; place-items: center;
}
.c-art > svg { height: 62%; max-width: 40%; width: auto; color: var(--card); filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); }
.c-rarity {
  position: absolute; bottom: -2.8cqw; left: 50%; transform: translateX(-50%);
  font: 800 3.4cqw/1 var(--sans); letter-spacing: .16em; text-transform: uppercase;
  background: var(--rc); color: #fff; padding: 1.4cqw 3cqw; border-radius: 5px; white-space: nowrap;
}
.card.legendary .c-rarity { color: #2b1f05; }

/* ---------- Condition by rarity ----------
   common: creased, foxed and edge-worn · uncommon: handled · rare: light toning
   epic: clean with a soft sheen · legendary: pristine, gilded, metal sheen */
.card {
  --edge: 0 0 0 transparent;
  --lattice-mask: var(--wear);
  background-image: var(--grime, none), linear-gradient(160deg, var(--card) 0%, var(--card-edge) 100%);
}
.card::before { -webkit-mask-image: var(--lattice-mask); mask-image: var(--lattice-mask); }

.card.common {
  --edge: inset 0 0 9cqw rgba(110, 68, 22, .3);
  --grime:
    linear-gradient(118deg, transparent 58.6%, rgba(96, 62, 24, .14) 58.9%, rgba(255, 250, 235, .45) 59.2%, transparent 59.8%),
    linear-gradient(12deg, transparent 31.5%, rgba(96, 62, 24, .08) 31.8%, rgba(255, 250, 235, .3) 32.1%, transparent 32.6%),
    radial-gradient(ellipse 30% 22% at 88% 92%, rgba(120, 78, 28, .08), transparent 70%),
    radial-gradient(ellipse 22% 16% at 8% 30%, rgba(120, 78, 28, .05), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.09' numOctaves='2' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5  0 0 0 0 .33  0 0 0 0 .12  9 0 0 0 -6.1'/%3E%3C/filter%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35  0 0 0 0 .24  0 0 0 0 .1  0 0 0 0 .055'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3Crect width='100%25' height='100%25' filter='url(%23f)' opacity='.22'/%3E%3C/svg%3E");
  background-color: #e9dcbd;
}
.card.common .c-art { filter: saturate(.75) sepia(.18); }
.card.common .c-head, .card.common .c-stats { filter: contrast(.92); }

.card.uncommon {
  --edge: inset 0 0 7cqw rgba(110, 68, 22, .26);
  --grime:
    linear-gradient(118deg, transparent 58.8%, rgba(96, 62, 24, .1) 59%, rgba(255, 250, 235, .35) 59.2%, transparent 59.6%),
    radial-gradient(ellipse 26% 18% at 90% 90%, rgba(120, 78, 28, .09), transparent 70%);
}
.card.rare { --edge: inset 0 0 5cqw rgba(110, 68, 22, .14); }

.card.epic { --lattice-mask: none; }
.card.epic::before { opacity: .7; }

.card.legendary {
  --lattice-mask: none;
  border-color: #5e410b;
  background: linear-gradient(160deg, #fdf8ec 0%, #f3e7ca 100%);
  box-shadow: 0 0 22px rgba(240, 200, 90, .35), 0 12px 26px rgba(0,0,0,.4);
}
.card.legendary > .frame {
  box-shadow: none; padding: 2.2cqw;
  background: linear-gradient(135deg, #7a5410 0%, #e9c766 14%, #fff4c8 24%, #b9881e 38%, #f6dc85 52%, #fffbe6 58%, #a8771a 72%, #eecf74 86%, #6f4c0e 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.card.legendary::before {
  background-image:
    repeating-linear-gradient(45deg, rgba(176, 128, 30, .2) 0 1px, transparent 1px 30cqw),
    repeating-linear-gradient(-45deg, rgba(176, 128, 30, .2) 0 1px, transparent 1px 30cqw),
    repeating-linear-gradient(45deg, rgba(176, 128, 30, .08) 0 1px, transparent 1px 7.5cqw),
    repeating-linear-gradient(-45deg, rgba(176, 128, 30, .08) 0 1px, transparent 1px 7.5cqw);
}
.card.legendary::after {
  background: linear-gradient(112deg, transparent 32%, rgba(255, 246, 210, .0) 38%, rgba(255, 246, 210, .85) 46%, rgba(255, 255, 255, .95) 49%, rgba(255, 236, 170, .7) 52%, transparent 62%);
  background-size: 260% 100%; background-repeat: no-repeat;
  mix-blend-mode: overlay;
  animation-duration: 3.6s;
}
.card.legendary .corner b {
  background: linear-gradient(180deg, #d9a62a 0%, #9a6a0e 50%, #c8921c 68%, #6a4708 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 1px 0 rgba(255, 244, 205, .8));
}
.card.legendary .c-rarity {
  background: linear-gradient(135deg, #8a5d0c, #f3d372 30%, #fff6cf 50%, #d9a62a 70%, #8a5d0c);
  color: #3a2604; box-shadow: 0 0 0 1px #5e410b;
}
.card.legendary .c-art { border-color: #9a6c14; box-shadow: inset 0 0 0 1px rgba(255, 236, 170, .6); }

.c-stats { display: grid; grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(3, auto); grid-auto-flow: column; gap: 2.2cqw 5cqw; align-content: center; padding-top: 3cqw; }
.stat { display: grid; grid-template-columns: 9.5cqw 1fr 5cqw 5.5cqw; align-items: center; gap: 1.6cqw; font-variant-numeric: tabular-nums; }
.stat .ab { font: 800 3.8cqw/1 var(--sans); letter-spacing: .06em; color: var(--ink-soft); }
.stat .v { font: 800 4.6cqw/1 var(--sans); text-align: right; }
.stat.key1 .ab, .stat.key1 .v, .stat.key2 .ab, .stat.key2 .v { color: var(--ink); }
.stat.key1 .ab { text-decoration: underline 0.5cqw; text-underline-offset: 0.8cqw; }
.stat.key2 .ab { text-decoration: underline dotted 0.5cqw; text-underline-offset: 0.8cqw; }
/* Level in the top-right corner, mirroring the stat total on the left */
.corner.tr { top: 5.5%; right: 6.5%; }
.corner.tr b { color: var(--ink-soft); }
.corner.tr.up b { color: var(--ink); }
/* XP ring round the level: starts at the top and fills anticlockwise.
   (An SVG circle's stroke starts at 3 o'clock going clockwise; mirroring it and turning it
   a quarter turn puts the start at 12 o'clock going anticlockwise.) */
.corner .lvl { position: relative; display: grid; place-items: center; width: 15.5cqw; aspect-ratio: 1; margin: -3.2cqw -3.2cqw 0; }
.corner .lvl b { position: relative; }
.xp-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(90deg) scaleX(-1); overflow: visible; }
.xp-ring circle { fill: none; stroke-width: 2.4; }
.xp-ring .track { stroke: rgba(43, 33, 24, .13); }
.xp-ring .fill { stroke: var(--rc); stroke-linecap: round; }
.card.common .xp-ring .fill { stroke: #7d8078; }
.card.legendary .xp-ring .fill { stroke: #c08a12; }
.corner.tr i { margin-top: .4cqw; }
.card.legendary .corner.tr b { color: #8a5d0c; }
/* Hit points in a heart, bottom right */
/* Hit points: a heart on the art panel's bottom-right corner, mirroring the rarity pill. */
.heart { position: absolute; right: -3cqw; bottom: -3.6cqw; z-index: 1; width: 12.5cqw; aspect-ratio: 32 / 29; display: grid; place-items: center; }
.heart svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: #b8392e; stroke: #6e1d16; stroke-width: 1.2; filter: drop-shadow(0 .5cqw .6cqw rgba(60, 10, 5, .35)); }
.heart b { position: relative; margin-top: -.8cqw; font: 800 4.8cqw/1 var(--sans); color: #fff4e6; text-shadow: 0 1px 1px rgba(60, 10, 5, .6); font-variant-numeric: tabular-nums; }
.stat.max .v { color: var(--rc); }
.bar { position: relative; height: 2.2cqw; border-radius: 1px; background: rgba(43,33,24,.13); overflow: hidden; }
.bar::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: rgba(244,236,218,.8); }
.bar span { display: block; height: 100%; background: var(--ink-soft); }
.stat.key1 .bar span, .stat.key2 .bar span { background: var(--ink); }
.stat.max .bar span { background: var(--rc); }
.stat .m { font: 700 3.2cqw/1 var(--sans); color: var(--ink-soft); text-align: right; }
/* the pen beside a hero's title (their Stats page, when they have more than one): choose which they go by */
.c-title .title-edit { display: inline-grid; place-items: center; vertical-align: .2cqw; width: 5.6cqw; height: 5.6cqw; margin-left: 1.2cqw; padding: 0; border: 1px solid color-mix(in srgb, var(--tc, var(--rc)) 70%, transparent); border-radius: 1.2cqw; background: rgba(255, 255, 255, .55); color: var(--ink); cursor: pointer; font-style: normal; }
.c-title .title-edit svg { width: 3.6cqw; height: 3.6cqw; }
.c-title .title-edit:hover, .c-title .title-edit:focus-visible { background: #fff; border-color: var(--tc, var(--rc)); }
