/*
 * The parts of a profile's look that the home page's cards share: the three
 * theme colours (as custom properties), and the font and pattern (picked by
 * name, as data attributes). Loaded by public profiles and by the app.
 */

/* Typed tokens: if one is ever set to something that isn't a colour, the browser ignores it. */
@property --profile-accent {
  syntax: "<color>";
  inherits: true;
  initial-value: #ff00ff;
}

@property --profile-text {
  syntax: "<color>";
  inherits: true;
  initial-value: #f4f0ff;
}

@property --profile-background {
  syntax: "<color>";
  inherits: true;
  initial-value: #14002a;
}

:is(.glitterbox-profile, .profile-card) {
  --profile-soft: color-mix(in srgb, var(--profile-accent) 30%, transparent);
  --profile-font: "Comic Sans MS", "Comic Neue", "Chalkboard SE", cursive;

  background-color: var(--profile-background);
  color: var(--profile-text);
  font-family: var(--profile-font);
}

/* Fonts */
:is(.glitterbox-profile, .profile-card)[data-font="comic"] { --profile-font: "Comic Sans MS", "Comic Neue", "Chalkboard SE", cursive; }
:is(.glitterbox-profile, .profile-card)[data-font="impact"] { --profile-font: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif; }
:is(.glitterbox-profile, .profile-card)[data-font="typewriter"] { --profile-font: "Courier New", Courier, ui-monospace, monospace; }
:is(.glitterbox-profile, .profile-card)[data-font="serif"] { --profile-font: Georgia, "Times New Roman", serif; }
:is(.glitterbox-profile, .profile-card)[data-font="rounded"] { --profile-font: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif; }
:is(.glitterbox-profile, .profile-card)[data-font="system"] { --profile-font: system-ui, sans-serif; }

/* Background patterns, all drawn with CSS: no images to host, moderate or track people with. */
:is(.glitterbox-profile, .profile-card)[data-pattern="starfield"] {
  background-image:
    radial-gradient(circle at 20% 30%, #fff 0 1px, transparent 1.5px),
    radial-gradient(circle at 70% 60%, var(--profile-accent) 0 1.5px, transparent 2px),
    radial-gradient(circle at 45% 85%, #fff 0 0.8px, transparent 1.2px);
  background-size: 140px 140px, 90px 90px, 55px 55px;
}

:is(.glitterbox-profile, .profile-card)[data-pattern="glitter"] {
  background-image:
    radial-gradient(var(--profile-accent) 0 1.5px, transparent 2.5px),
    radial-gradient(#fff 0 1px, transparent 2px),
    radial-gradient(var(--profile-soft) 0 3px, transparent 4px);
  background-size: 26px 26px, 37px 37px, 61px 61px;
  background-position: 0 0, 13px 19px, 30px 7px;
}

:is(.glitterbox-profile, .profile-card)[data-pattern="checkerboard"] {
  background-image: conic-gradient(var(--profile-soft) 25%, transparent 0 50%, var(--profile-soft) 0 75%, transparent 0);
  background-size: 48px 48px;
}

:is(.glitterbox-profile, .profile-card)[data-pattern="stripes"] {
  background-image: repeating-linear-gradient(45deg, var(--profile-soft) 0 14px, transparent 14px 28px);
}

:is(.glitterbox-profile, .profile-card)[data-pattern="sunset"] {
  background-image:
    linear-gradient(transparent 55%, var(--profile-soft)),
    repeating-linear-gradient(90deg, var(--profile-soft) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg, var(--profile-soft) 0 1px, transparent 1px 64px);
}

/*
 * Seasonal patterns, for dressing up during a competition (see Competition::THEMES).
 * Still all CSS: profiles can only load images from their own host, so even a
 * data: URL picture is out.
 */
:is(.glitterbox-profile, .profile-card)[data-pattern="cobwebs"] {
  /* A web in the top corner: rings, and threads coming out from the corner. */
  background-image:
    repeating-radial-gradient(circle at 0 0, transparent 0 34px, var(--profile-soft) 34px 35.5px),
    repeating-conic-gradient(from 90deg at 0 0, var(--profile-soft) 0 0.7deg, transparent 0.7deg 15deg);
  background-size: 100% 100%, 100% 100%;
  background-repeat: no-repeat;
}

:is(.glitterbox-profile, .profile-card)[data-pattern="snowfall"] {
  background-image:
    radial-gradient(circle at 25% 20%, #fff 0 2px, transparent 2.5px),
    radial-gradient(circle at 70% 55%, #fffc 0 3px, transparent 3.5px),
    radial-gradient(circle at 40% 80%, #fff9 0 1.5px, transparent 2px),
    radial-gradient(circle at 85% 10%, var(--profile-soft) 0 4px, transparent 4.5px);
  background-size: 90px 90px, 130px 130px, 60px 60px, 170px 170px;
}

/* On a profile (not a little card), the snow falls, slowly. */
.glitterbox-profile[data-pattern="snowfall"] { animation: glitterbox-snowfall 30s linear infinite; }
@keyframes glitterbox-snowfall {
  to { background-position: 18px 900px, -26px 1040px, 12px 960px, -34px 1020px; }
}
@media (prefers-reduced-motion: reduce) {
  .glitterbox-profile[data-pattern="snowfall"] { animation: none; }
}

:is(.glitterbox-profile, .profile-card)[data-pattern="hearts"] {
  /*
   * A heart is two circles on top of a "V". Gradients can only add shapes, not
   * cut them, so the V is a wedge that would carry on up to the top of the
   * tile, and a strip of plain background is painted over the part above the
   * circles. (Layers are listed top first.)
   */
  /* Solid, not see-through: where the circles and the V overlap, they'd show darker seams. */
  --heart: color-mix(in srgb, var(--profile-accent) 30%, var(--profile-background));
  background-image:
    radial-gradient(circle at 21px 22px, var(--heart) 0 7px, transparent 7.5px),
    radial-gradient(circle at 35px 22px, var(--heart) 0 7px, transparent 7.5px),
    linear-gradient(var(--profile-background) 0 22px, transparent 22px),
    conic-gradient(from -38deg at 28px 40px, var(--heart) 0 76deg, transparent 0);
  background-size: 56px 56px;
}

:is(.glitterbox-profile, .profile-card)[data-pattern="sunshine"] {
  /* A sun in the corner, and its rays. */
  background-image:
    radial-gradient(circle at 90% 0, var(--profile-accent) 0 56px, var(--profile-soft) 58px 72px, transparent 74px),
    repeating-conic-gradient(from 0deg at 90% 0, var(--profile-soft) 0 5deg, transparent 5deg 15deg);
  background-size: 100% 100%, 100% 100%;
  background-repeat: no-repeat;
}
