/* com_games base styles. Colours/fonts come from the template's tokens when it defines them (tpl_gaming does). */
.com-games {
  --g-bg: var(--surface, #fff);
  --g-text: var(--text, #15151f);
  --g-muted: var(--text-muted, #5c5c70);
  --g-accent: var(--accent, #6d28d9);
  --g-on-accent: var(--on-accent, #fff);
  --g-card: var(--surface-raised, #fff);
  --g-line: var(--line, #e2e2ea);
  --g-radius: var(--radius-lg, 20px);
  --g-display: var(--font-display, system-ui, sans-serif);
  color: var(--g-text);
}

/* ---------- catalogue ---------- */
.games__head { margin-block: 0 1.5rem; }
.games__title { font-family: var(--g-display); margin: 0; }
.games__intro { color: var(--g-muted); max-width: 60ch; }
.games__grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
}
.game-card__link {
  display: flex; flex-direction: column; height: 100%;
  background: var(--g-card); color: inherit; text-decoration: none;
  border: 1px solid var(--g-line); border-radius: var(--g-radius); overflow: hidden;
  box-shadow: 0 2px 0 var(--g-line);
  transition: transform .15s ease, box-shadow .15s ease;
}
.game-card__link:hover { transform: translateY(-4px); box-shadow: 0 10px 24px rgb(0 0 0 / .12); }
.game-card__link:focus-visible { outline: 3px solid var(--g-accent); outline-offset: 3px; }
.game-card__cover { display: block; aspect-ratio: 1200 / 630; background: var(--g-accent); }
.game-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game-card__placeholder {
  display: grid; place-items: center; height: 100%;
  font: 4rem/1 var(--g-display); color: var(--g-on-accent);
}
.game-card__body { display: flex; flex-direction: column; gap: .5rem; padding: 1rem 1.25rem 1.25rem; flex: 1; }
.game-card__title { font: 1.4rem/1.15 var(--g-display); }
.game-card__desc { color: var(--g-muted); font-size: .95rem; }
.game-card__cta { margin-top: auto; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding-top: .5rem; }
.btn-play {
  display: inline-block; padding: .55rem 1.2rem; border-radius: 999px;
  background: var(--g-accent); color: var(--g-on-accent);
  font: 1rem/1.2 var(--g-display); letter-spacing: .02em;
}
.game-card__saved { color: var(--g-muted); font-size: .85rem; }
.games__empty, .games__login-hint { color: var(--g-muted); }

/* ---------- game page ---------- */
.game-stage {
  display: flex; flex-direction: column;
  height: calc(100dvh - var(--stage-offset, 0px)); min-height: 320px;
  background: #000;
}
.game-bar {
  display: flex; align-items: center; gap: .75rem;
  padding: .4rem max(.75rem, env(safe-area-inset-right)) .4rem max(.75rem, env(safe-area-inset-left));
  background: var(--g-card); border-bottom: 1px solid var(--g-line);
  min-height: 44px;
}
.game-bar__back { color: inherit; text-decoration: none; font-weight: 600; white-space: nowrap; }
.game-bar__title { font: 1.1rem/1.2 var(--g-display); margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-bar__status { color: var(--g-muted); font-size: .85rem; white-space: nowrap; }
.game-bar__status.is-error { color: #b42318; font-weight: 600; }
.game-bar__fs {
  border: 1px solid var(--g-line); background: transparent; color: inherit;
  border-radius: 10px; width: 36px; height: 36px; font-size: 1.1rem; cursor: pointer;
}
.game-frame { flex: 1; width: 100%; border: 0; display: block; background: #000; }
.game-missing { color: #fff; padding: 2rem; text-align: center; }
.game-stage:fullscreen .game-bar { display: none; }
@media (max-width: 599px) { .game-bar__label { display: none; } }

/* ---------- history ---------- */
.history__save-list { list-style: none; padding: 0; display: grid; gap: .5rem; }
.history__save-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border: 1px solid var(--g-line); border-radius: 12px; background: var(--g-card); }
.history__table-wrap { overflow-x: auto; }
.history__table { width: 100%; border-collapse: collapse; }
.history__table th, .history__table td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--g-line); }
.history__table .num { text-align: right; font-variant-numeric: tabular-nums; }
.history__table thead th { color: var(--g-muted); font-weight: 600; font-size: .85rem; }

@media (prefers-reduced-motion: reduce) { .game-card__link { transition: none; } .game-card__link:hover { transform: none; } }

/* ---------- profile (/mon-profil) ---------- */
.avatar { display: block; border-radius: 50%; object-fit: cover; background: var(--g-card); }
.gp {
  --gp-page: var(--bg, #f6f5fc);
  --gp-link: var(--link, var(--g-accent));
  --gp-pop: var(--pop, #ff4d8d);
  --gp-sun: var(--sun, #ffc53d);
  --gp-danger: var(--danger, #b42318);
  --gp-r: var(--radius, 12px);
  --gp-shadow: var(--shadow, 0 8px 24px rgb(0 0 0 / .08));
  --gp-focus: var(--g-accent);
  --gp-field-line: color-mix(in srgb, var(--g-muted) 70%, var(--g-card)); /* >= 3:1 on the card */
  --gp-tint: color-mix(in srgb, var(--g-accent) 8%, var(--g-card));
}
[data-theme="dark"] .gp { --gp-focus: color-mix(in srgb, var(--g-accent) 50%, #fff); --gp-tint: color-mix(in srgb, var(--g-accent) 16%, var(--g-card)); }
.gp :focus-visible { outline: 3px solid var(--gp-focus); outline-offset: 3px; }
.gp-muted, .gp-hint { color: var(--g-muted); }
.gp-hint { margin: 0; font-size: .9rem; }

/* buttons: chunky arcade pills (match tpl_gaming .btn--accent) */
.gp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: .55rem 1.4rem; border: 2px solid transparent; border-radius: 999px; cursor: pointer;
  background: var(--g-accent); color: var(--g-on-accent); text-decoration: none;
  font: 1.15rem/1.15 var(--g-display); letter-spacing: .02em;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--g-accent) 60%, #000);
  transition: transform .1s ease, box-shadow .1s ease;
}
.gp-btn:hover { transform: translateY(-1px); color: var(--g-on-accent); }
.gp-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 color-mix(in srgb, var(--g-accent) 60%, #000); }
.gp-btn--big { min-height: 54px; padding-inline: 1.8rem; font-size: 1.3rem; }
.gp-btn--block { width: 100%; }
.gp-btn--ghost { background: var(--g-card); color: var(--g-text); border-color: var(--g-text); box-shadow: 0 3px 0 var(--g-text); }
.gp-btn--ghost:hover { color: var(--g-text); }
.gp-btn--ghost:active { box-shadow: 0 1px 0 var(--g-text); }
.gp-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--gp-link); font-weight: 700; }

/* hero: the player card */
.gp-hero {
  background: var(--g-card); border: 2px solid var(--g-line); border-radius: var(--g-radius);
  box-shadow: 0 6px 0 var(--g-accent), var(--gp-shadow); overflow: hidden;
  margin-block-end: clamp(1.75rem, 4vw, 2.5rem);
}
.gp-hero__banner {
  height: clamp(96px, 14vw, 150px);
  background:
    linear-gradient(115deg, transparent 0 64%, var(--gp-pop) 64% 71%, var(--gp-sun) 71% 75%, transparent 75%),
    radial-gradient(circle at 2px 2px, color-mix(in srgb, var(--g-on-accent) 18%, transparent) 1.5px, transparent 0) 0 0 / 20px 20px,
    var(--g-accent);
}
.gp-hero__id {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1.5rem;
  padding: 0 clamp(1rem, 4vw, 2rem);
}
.gp-hero__avatar {
  width: clamp(112px, 15vw, 152px); height: auto; aspect-ratio: 1;
  margin-top: calc(clamp(112px, 15vw, 152px) * -.5); /* half of it rides on the banner */
  border: 5px solid var(--g-card); box-shadow: 0 0 0 4px var(--g-accent), 0 8px 0 4px color-mix(in srgb, var(--g-accent) 30%, transparent);
  background: var(--g-card);
}
.gp-hero__text { flex: 1 1 16rem; min-width: 0; padding-block-start: .75rem; }
.gp-hero__kicker { margin: 0; color: var(--gp-link); font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; }
.gp-hero__name { margin: .1rem 0 .15rem; font: clamp(2rem, 5vw, 3.2rem)/1.05 var(--g-display); overflow-wrap: anywhere; }
.gp-hero__since { margin: 0; color: var(--g-muted); }
.gp-hero__edit { margin-inline-start: auto; }
.gp-tiles {
  display: grid; gap: .75rem; margin: 0; padding: clamp(1rem, 3vw, 1.5rem) clamp(1rem, 4vw, 2rem) clamp(1.25rem, 3vw, 1.75rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr));
}
.gp-tile {
  display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: .15rem;
  padding: .8rem 1rem; border-radius: var(--gp-r); background: var(--gp-tint);
  border-top: 4px solid var(--g-accent);
}
.gp-tile:nth-child(2) { border-top-color: var(--gp-pop); }
.gp-tile:nth-child(3) { border-top-color: var(--gp-sun); }
.gp-tile dt { color: var(--g-muted); font-weight: 700; font-size: .85rem; }
.gp-tile dd { margin: 0; font: 2.2rem/1 var(--g-display); font-variant-numeric: tabular-nums; }
.gp-tile--when dd { font-size: 1.3rem; line-height: 1.15; padding-block: .3rem .2rem; }
@media (max-width: 599px) {
  .gp-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
  .gp-tile { padding: .7rem .75rem; }
  .gp-tile dt { font-size: .78rem; line-height: 1.25; hyphens: auto; overflow-wrap: anywhere; }
  .gp-tile { min-width: 0; }
  .gp-tile dd { font-size: 1.9rem; }
  .gp-tile--when { grid-column: 1 / -1; }
  .gp-tile--when dd { font-size: 1.2rem; }
  .gp-hero__edit { margin-inline-start: 0; }
}

/* layout: games + activity, edit panel on the side */
.gp-layout { display: grid; gap: clamp(1.75rem, 4vw, 2.5rem); }
@media (min-width: 1000px) { .gp-layout { grid-template-columns: minmax(0, 1fr) minmax(320px, 380px); align-items: start; } }
.gp-main { display: grid; gap: clamp(1.75rem, 4vw, 2.5rem); min-width: 0; container-type: inline-size; }
.gp-section__title { margin: 0 0 1rem; font: clamp(1.5rem, 3vw, 2rem)/1.1 var(--g-display); }
.gp-section__more { margin: .5rem 0 0; }

/* my games */
.gp-games { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.25rem; }
.gp-game {
  display: grid; overflow: hidden;
  background: var(--g-card); border: 2px solid var(--g-line); border-radius: var(--g-radius); box-shadow: var(--gp-shadow);
  transition: box-shadow .15s ease, transform .15s ease;
}
.gp-game:hover, .gp-game:focus-within { box-shadow: 0 6px 0 var(--g-accent), var(--gp-shadow); }
.gp-game__cover { aspect-ratio: 1200 / 630; background: var(--g-accent); overflow: hidden; }
.gp-game__cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gp-game__placeholder { display: grid; place-items: center; height: 100%; font: 4rem/1 var(--g-display); color: var(--g-on-accent); }
.gp-game__body { display: flex; flex-direction: column; gap: 1rem; padding: 1.1rem 1.25rem 1.25rem; min-width: 0; }
.gp-game__title { margin: 0; font: 1.6rem/1.1 var(--g-display); }
.gp-game__meta { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1rem; }
.gp-game__meta dt { color: var(--g-muted); font-size: .85rem; font-weight: 600; }
.gp-game__meta dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.gp-game__actions { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; }
@container (min-width: 600px) {
  .gp-game { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
  .gp-game__cover { aspect-ratio: auto; min-height: 100%; }
  .gp-game__cover img { object-position: left center; } /* covers carry their title on the left */
}
@container (max-width: 359px) { .gp-game__actions .gp-btn { width: 100%; } }

/* recent activity */
.gp-feed { list-style: none; margin: 0; padding: 0; background: var(--g-card); border: 2px solid var(--g-line); border-radius: var(--g-radius); overflow: hidden; }
.gp-feed__item { display: grid; gap: .3rem; padding: .9rem 1.25rem .9rem 2.6rem; position: relative; }
.gp-feed__item + .gp-feed__item { border-top: 1px solid var(--g-line); }
.gp-feed__item::before {
  content: ""; position: absolute; left: 1.1rem; top: 1.25rem; width: .7rem; height: .7rem; border-radius: 3px;
  background: var(--g-accent); transform: rotate(45deg);
}
.gp-feed__item:nth-child(3n+2)::before { background: var(--gp-pop); }
.gp-feed__item:nth-child(3n)::before { background: var(--gp-sun); }
.gp-feed__label { font-weight: 700; overflow-wrap: anywhere; }
.gp-feed__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .9rem; color: var(--g-muted); font-size: .9rem; }
.gp-feed__game { padding: .05rem .6rem; border-radius: 999px; background: var(--gp-tint); color: var(--gp-link); font-weight: 700; }

/* empty state */
.gp-empty { display: grid; gap: 1rem; justify-items: start; padding: 1.5rem; border-radius: var(--g-radius); background: color-mix(in srgb, var(--gp-sun) 22%, var(--g-card)); }
.gp-empty p { margin: 0; font-size: 1.05rem; }

/* edit panel */
.gp-panel {
  background: var(--g-card); border: 2px solid var(--g-line); border-radius: var(--g-radius);
  box-shadow: 0 6px 0 var(--g-accent), var(--gp-shadow); padding: clamp(1.1rem, 4vw, 1.75rem);
  scroll-margin-top: 88px; min-width: 0;
}
.gp-panel:focus { outline: none; }
.gp-panel:target { box-shadow: 0 6px 0 var(--gp-pop), var(--gp-shadow); }
.gp-form { display: grid; gap: 1.5rem; }
.gp-field { display: grid; gap: .4rem; min-width: 0; margin: 0; padding: 0; border: 0; }
.gp-field > label, .gp-field > legend { font: 700 1rem/1.3 var(--font-body, system-ui, sans-serif); margin: 0 0 .1rem; padding: 0; }
.gp-field input[type="text"] {
  width: 100%; min-height: 48px; padding: .6rem .85rem; font: inherit; font-size: 1rem; color: var(--g-text);
  background: var(--gp-page); border: 2px solid var(--gp-field-line); border-radius: var(--gp-r);
}
.gp-field input[type="text"]:focus { outline: none; border-color: var(--gp-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gp-focus) 35%, transparent); }

.gp-avatars { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); margin-top: .35rem; }
.gp-avatar { position: relative; display: block; margin: 0; cursor: pointer; border-radius: 18px; }
.gp-avatar input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.gp-avatar img {
  display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover;
  border-radius: 18px; border: 3px solid transparent; background: var(--gp-tint);
  transition: transform .12s ease;
}
.gp-avatar:hover img { transform: translateY(-2px); }
.gp-avatar:has(input:checked) img { border-color: var(--g-card); box-shadow: 0 0 0 3px var(--g-accent); }
.gp-avatar:has(input:checked)::after {
  content: ""; position: absolute; right: -4px; top: -4px; width: 22px; height: 22px; border-radius: 50%; pointer-events: none;
  background: var(--gp-sun) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-6.5' fill='none' stroke='%2317142b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 13px no-repeat;
  box-shadow: 0 0 0 2px var(--g-card);
}
.gp-avatar:has(input:focus-visible) { outline: 3px solid var(--gp-focus); outline-offset: 4px; }

.gp-drop {
  position: relative; display: flex; align-items: center; gap: 1rem; min-height: 96px; padding: 1rem 1.1rem;
  border: 2px dashed var(--gp-field-line); border-radius: var(--gp-r); background: var(--gp-page);
  transition: border-color .12s ease, background-color .12s ease;
}
.gp-drop input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.gp-drop:hover, .gp-drop.is-over { border-color: var(--g-accent); background: var(--gp-tint); }
.gp-drop:has(input:focus-visible) { outline: 3px solid var(--gp-focus); outline-offset: 3px; }
.gp-drop.has-file { border-style: solid; border-color: var(--g-accent); }
.gp-drop.is-error { border-color: var(--gp-danger); }
.gp-drop__icon {
  flex: 0 0 52px; height: 52px; border-radius: 50%; background: var(--gp-sun); box-shadow: 0 3px 0 rgb(0 0 0 / .2);
  position: relative;
}
.gp-drop__icon::before {
  content: ""; position: absolute; inset: 0; margin: auto; width: 26px; height: 26px; background: #17142b;
  -webkit-mask: var(--gp-up) center / contain no-repeat; mask: var(--gp-up) center / contain no-repeat;
  --gp-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 16V4m-5 5 5-5 5 5M4 20h16'/%3E%3C/svg%3E");
}
.gp-drop.has-file .gp-drop__icon { display: none; }
.gp-drop__preview { flex: 0 0 64px; width: 64px; height: 64px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 3px var(--g-accent); }
.gp-drop__text { font-weight: 700; line-height: 1.3; }
.gp-drop__status { margin: 0; font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; }
.gp-drop__status:empty { display: none; }
.gp-field:has(.is-error) .gp-drop__status { color: var(--gp-danger); }

@media (prefers-reduced-motion: reduce) {
  .gp-btn, .gp-game, .gp-avatar img, .gp-drop { transition: none; }
  .gp-btn:hover, .gp-avatar:hover img { transform: none; }
}

/* ---------- community (OuiShare space link) ---------- */
.game-card { position: relative; }
.game-card__community, .game-bar__community {
  display: inline-block; padding: .3rem .8rem; border-radius: 999px; text-decoration: none;
  font: .95rem/1.2 var(--g-display); white-space: nowrap;
  background: var(--g-card); color: var(--g-text); border: 1px solid var(--g-line);
}
.game-card__community { position: absolute; top: .6rem; right: .6rem; box-shadow: 0 2px 8px rgb(0 0 0 / .2); }
.game-card__community:hover, .game-bar__community:hover { border-color: var(--g-accent); }
.game-card__community:focus-visible, .game-bar__community:focus-visible { outline: 3px solid var(--g-accent); outline-offset: 2px; }
.game-stage:fullscreen .game-bar__community { display: none; }
