@number_color: default;
@number_size: default;
@title_color: default;
@title_size: default;
@icon_color: default;
@icon_size: default;

.zaso-counter {

  &__inner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  &__icon {
    color: @icon_color;
    font-size: @icon_size;
    line-height: 1;

    .sow-icon-fontawesome,
    [class^="sow-fa"],
    [class*=" sow-fa"],
    span {
      font-size: @icon_size;
      color: @icon_color;
    }
  }

  &__image {
    width: @icon_size;
    height: auto;
    display: inline-block;
  }

  &__number {
    color: @number_color;
    font-size: @number_size;
    font-weight: 700;
    line-height: 1.1;
  }

  &__title {
    color: @title_color;
    font-size: @title_size;
    line-height: 1.3;
  }

  // Alignment modifiers.
  &--align-left {
    text-align: left;

    .zaso-counter__inner {
      align-items: flex-start;
    }
  }

  &--align-center {
    text-align: center;

    .zaso-counter__inner {
      align-items: center;
    }
  }

  &--align-right {
    text-align: right;

    .zaso-counter__inner {
      align-items: flex-end;
    }
  }
}

// ===========================================================================
// LAYOUT VARIANTS (structure only)
// ---------------------------------------------------------------------------
// Orthogonal to the colour skins. The Style preset still drives number / title
// / icon colour and size via the colour vars above; these rules only restructure
// shape (surface, padding, radius, shadow, row vs column, ring). The "default"
// layout adds no class and is intentionally untouched here. The Counter has no
// background field, so surfaces are neutral (white) or transparent, keeping the
// AA-safe-on-light contract the skins are built against.
// ===========================================================================

// ----- Layout: card --------------------------------------------------------
// Wraps the whole stat in an elevated neutral card: soft white surface, hairline
// border, generous padding, large radius, layered shadow. Colours are untouched,
// so every skin keeps its AA contrast against the white card.
.zaso-counter--layout-card .zaso-counter__inner {
  background: #ffffff;
  border: 1px solid rgba( 15, 23, 42, 0.1 );
  border-radius: 16px;
  padding: 2rem 1.75rem;
  box-shadow: 0 12px 30px -12px rgba( 15, 23, 42, 0.22 ), 0 2px 6px rgba( 15, 23, 42, 0.06 );
}

// ----- Layout: inline ------------------------------------------------------
// Icon and number sit on one row; the title wraps to a full-width line beneath.
// Cross-axis centring keeps the icon optically aligned with the number. The
// horizontal placement follows the chosen alignment via justify-content.
.zaso-counter--layout-inline .zaso-counter__inner {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.5rem;
}

.zaso-counter--layout-inline .zaso-counter__title {
  flex-basis: 100%;
}

.zaso-counter--layout-inline.zaso-counter--align-left .zaso-counter__inner {
  justify-content: flex-start;
}

.zaso-counter--layout-inline.zaso-counter--align-center .zaso-counter__inner {
  justify-content: center;
}

.zaso-counter--layout-inline.zaso-counter--align-right .zaso-counter__inner {
  justify-content: flex-end;
}

// ----- Layout: circle ------------------------------------------------------
// The number is the hero, set inside a premium accent ring. The ring is a
// masked conic-gradient donut (a clean "progress-ring" feel with a soft accent
// sheen) painted as a pseudo-element, so its hole stays TRANSPARENT and the
// layout reads correctly on any page background, not just white. The decorative
// icon is intentionally dropped here so nothing floats above the ring and the
// ring + number stay balanced and optically centred. The title sits below.
.zaso-counter--layout-circle .zaso-counter__inner {
  gap: 1rem;
}

// Drop the icon in this layout: the ring is the visual, an icon above it just
// floats and unbalances the composition.
.zaso-counter--layout-circle .zaso-counter__icon {
  display: none;
}

.zaso-counter--layout-circle .zaso-counter__number {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: auto;
  min-width: 10.5rem;
  aspect-ratio: 1 / 1;
  padding: 1.9rem;
  border-radius: 50%;
}

// The ring is built from two masked donut layers, so it reads as a deliberate,
// premium accent rather than a hairline border. Because counters are frequently
// percentages, the accent fills the FULL ring (a partial arc would look like a
// broken progress value against, say, 99%). Both layers punch a TRANSPARENT hole
// via mask, so the centre shows the page background on any surface, not just
// white.
//
// Layer 1 (::before): a soft track ring for subtle depth under the accent.
.zaso-counter--layout-circle .zaso-counter__number::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: fade( @icon_color, 14% );
  // calc() is escaped (~"...") so the LESS compiler passes it through literally
  // instead of folding "100% - 0.82rem" into a unit-stripped percentage.
  -webkit-mask: radial-gradient( farthest-side, transparent calc( ~"100% - 0.82rem" ), #000 calc( ~"100% - 0.82rem" ) );
  mask: radial-gradient( farthest-side, transparent calc( ~"100% - 0.82rem" ), #000 calc( ~"100% - 0.82rem" ) );
  z-index: 0;
}

// Layer 2 (::after): the solid accent ring with a gentle conic sheen (low
// contrast so there is no faint dead zone) plus a soft accent-tinted shadow for
// lift. Slightly thinner than the track so a thin track halo stays visible.
.zaso-counter--layout-circle .zaso-counter__number::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient( from -90deg, @icon_color, lighten( @icon_color, 9% ) 50%, @icon_color );
  -webkit-mask: radial-gradient( farthest-side, transparent calc( ~"100% - 0.7rem" ), #000 calc( ~"100% - 0.7rem" ) );
  mask: radial-gradient( farthest-side, transparent calc( ~"100% - 0.7rem" ), #000 calc( ~"100% - 0.7rem" ) );
  filter: drop-shadow( 0 6px 16px fade( @icon_color, 28% ) );
  z-index: 0;
}

// Keep the number (and any prefix/suffix) optically centred above the ring.
.zaso-counter--layout-circle .zaso-counter__number > * {
  position: relative;
  z-index: 1;
}

// ===========================================================================
// DESIGN VARIANTS (free): ready-made counter looks
// ---------------------------------------------------------------------------
// Hex values, sizes and glyphs tuned to the canonical Claude Design spec
// ("Counter Widget.dc.html"). Each variant is a self-contained surface (card,
// number colour + size, label, optional icon box, structural extras). Every
// rule is scoped under .zaso-counter--design-* so the default render and all
// existing instances stay byte-identical. The number font weight is 800 with a
// -0.02em tracking per the spec. The icon glyph itself comes from the existing
// Icon field (the demo / user picks the spec glyph: download, groups, bolt);
// these rules only style the icon BOX, so a counter with no icon set still
// reads correctly (icon optional). Pro ships 24 more designs in its own
// stylesheet; these six are the free set.
// ===========================================================================

// Shared number treatment for every free design.
.zaso-counter--design-icon-card .zaso-counter__number,
.zaso-counter--design-centered .zaso-counter__number,
.zaso-counter--design-icon-top .zaso-counter__number,
.zaso-counter--design-badge .zaso-counter__number,
.zaso-counter--design-divider .zaso-counter__number,
.zaso-counter--design-underline .zaso-counter__number {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

// ----- F01 Icon Card (success) --------------------------------------------
// Row: icon box on the left, number stacked over the label on the right.
// A CSS grid keeps the icon optically centred against the number + label pair
// without any extra markup. With no icon set the number + label simply fill the
// card.
.zaso-counter--design-icon-card .zaso-counter__inner {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 16px;
  row-gap: 0;
  text-align: left;
  background-color: #f0fdf4;
  border: 1px solid #dcfce7;
  border-radius: 14px;
  padding: 22px 24px;
}
.zaso-counter--design-icon-card .zaso-counter__icon {
  grid-row: 1 / span 2;
  grid-column: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background-color: #dcfce7;
  font-size: 26px;
  line-height: 1;
  color: #16a34a;
}
.zaso-counter--design-icon-card .zaso-counter__icon span { font-size: 26px; color: #16a34a; }
.zaso-counter--design-icon-card .zaso-counter__image { width: 26px; }
.zaso-counter--design-icon-card .zaso-counter__number {
  grid-column: 2;
  align-self: end;
  font-size: 38px;
  color: #14532d;
}
.zaso-counter--design-icon-card .zaso-counter__title {
  grid-column: 2;
  align-self: start;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #3f6212;
}

// ----- F02 Centered (info) ------------------------------------------------
.zaso-counter--design-centered .zaso-counter__inner {
  align-items: center;
  text-align: center;
  gap: 0;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 26px 24px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}
.zaso-counter--design-centered .zaso-counter__number {
  font-size: 46px;
  color: #2563eb;
}
.zaso-counter--design-centered .zaso-counter__title {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
}

// ----- F03 Icon Top (installs) --------------------------------------------
// Stacked, centred. The glyph sits above the number as a bare block (no box),
// then the number with a coloured "+" suffix, then the label.
.zaso-counter--design-icon-top .zaso-counter__inner {
  align-items: flex-start;
  text-align: left;
  gap: 0;
  background-color: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 14px;
  padding: 22px 24px;
}
.zaso-counter--design-icon-top .zaso-counter__icon {
  display: block;
  margin-bottom: 10px;
  font-size: 24px;
  line-height: 1;
  color: #ea580c;
}
.zaso-counter--design-icon-top .zaso-counter__icon span { font-size: 24px; color: #ea580c; }
.zaso-counter--design-icon-top .zaso-counter__image { width: 24px; }
.zaso-counter--design-icon-top .zaso-counter__number {
  font-size: 40px;
  color: #9a3412;
}
.zaso-counter--design-icon-top .zaso-counter__suffix { font-size: 26px; color: #ea580c; }
.zaso-counter--design-icon-top .zaso-counter__title {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #c2410c;
}

// ----- F04 Badge (uptime) -------------------------------------------------
// Row: circular icon badge on the left, number (with "%" suffix) over the label
// on the right. Same grid technique as Icon Card.
.zaso-counter--design-badge .zaso-counter__inner {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 16px;
  row-gap: 0;
  text-align: left;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 20px 24px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}
.zaso-counter--design-badge .zaso-counter__icon {
  grid-row: 1 / span 2;
  grid-column: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: #eef2ff;
  font-size: 25px;
  line-height: 1;
  color: #4f46e5;
}
.zaso-counter--design-badge .zaso-counter__icon span { font-size: 25px; color: #4f46e5; }
.zaso-counter--design-badge .zaso-counter__image { width: 25px; }
.zaso-counter--design-badge .zaso-counter__number {
  grid-column: 2;
  align-self: end;
  font-size: 36px;
  color: #312e81;
}
.zaso-counter--design-badge .zaso-counter__suffix { font-size: 22px; color: #4f46e5; }
.zaso-counter--design-badge .zaso-counter__title {
  grid-column: 2;
  align-self: start;
  margin-top: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #4338ca;
}

// ----- F05 Divider (neutral) ----------------------------------------------
// Stacked. A hairline rule sits between the number and the label, rendered as a
// top border on the label (pseudo-free, no extra markup). With no label the
// card is just the number, which still reads cleanly.
.zaso-counter--design-divider .zaso-counter__inner {
  align-items: stretch;
  text-align: left;
  gap: 0;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 22px 24px;
}
.zaso-counter--design-divider .zaso-counter__number {
  justify-content: flex-start;
  font-size: 42px;
  color: #0f172a;
}
.zaso-counter--design-divider .zaso-counter__title {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
}

// ----- F06 Underline (rating) ---------------------------------------------
// Stacked. A short teal accent bar sits between the number and the label,
// rendered as a ::before on the label so no extra markup is needed. The number
// carries a muted "/5" suffix.
.zaso-counter--design-underline .zaso-counter__inner {
  align-items: flex-start;
  text-align: left;
  gap: 0;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 22px 24px;
}
.zaso-counter--design-underline .zaso-counter__number {
  font-size: 42px;
  color: #0f766e;
}
.zaso-counter--design-underline .zaso-counter__suffix {
  font-size: 18px;
  font-weight: 700;
  color: #94a3b8;
}
.zaso-counter--design-underline .zaso-counter__title {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
}
.zaso-counter--design-underline .zaso-counter__title::before {
  content: "";
  display: block;
  width: 40px;
  height: 3px;
  margin: 12px 0;
  border-radius: 2px;
  background-color: #14b8a6;
}
