@use 'sass:map';
@use 'variables' as *;

// ---- max-width media query: @include below(mobile) { ... } ----
@mixin below($name) {
  @media (max-width: map.get($breakpoints, $name)) {
    @content;
  }
}

// ---- Keyboard focus ring ----
@mixin focus-ring($offset: 3px) {
  &:focus-visible {
    outline: 2px solid var(--accent-deep);
    outline-offset: $offset;
  }
}

// ---- Glass blur ----
@mixin glass-blur($amount) {
  backdrop-filter: blur($amount);
  -webkit-backdrop-filter: blur($amount);
}

// ---- Clamp to a number of lines ----
@mixin line-clamp($lines) {
  display: -webkit-box;
  -webkit-line-clamp: $lines;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

// ---- Circle ----
@mixin circle($size) {
  width: $size;
  height: $size;
  border-radius: 50%;
}

// ---- The design's one-line form: an underlined field and a text button ----
// (the template's subscribe form; used by the search form, the "Below the
// posts" area and the Search block)
@mixin underline-field {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 4px;
  border: none;
  border-bottom: 1px solid var(--rule-strong);
  border-radius: 0;
  background: transparent;
  font-family: $font-sans;
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.28s ease;

  &::placeholder { color: var(--ink-faint); }
  &:focus { border-color: var(--accent); }
  // Replaces outline: none — a thicker border on keyboard focus
  &:focus-visible { border-bottom-width: 2px; border-color: var(--accent-deep); }
}

@mixin text-button {
  height: 44px;
  padding: 0 4px;
  border: none;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  font-family: $font-sans;
  font-size: 15px;
  color: var(--accent-deep);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.28s ease;

  &:hover { border-color: var(--accent); }
}

// ---- A page chip: post page links, comment and query pagination ----
@mixin page-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--hairline);
  border-radius: $pill-radius;
  background: var(--glass);
  color: var(--ink-soft);
  font-size: 14.5px;
  line-height: 1;
  text-decoration: none;

  &:hover { color: var(--accent-deep); }
  &.current { background: var(--btn-grad); color: var(--on-accent); border-color: transparent; }
  &.dots { border: 0; background: none; }
}
