/*
 * TalayOS UI Library
 * Original adaptations informed by the public Uiverse challenge briefs and
 * winning entries listed in THIRD_PARTY_NOTICES.md. No upstream markup copied.
 */

.ui-btn {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 18px;
  overflow: hidden;
  border: 0;
  border-radius: 13px;
  color: var(--color-text-primary);
  cursor: pointer;
  font-weight: 720;
  text-decoration: none;
  transition:
    transform 160ms var(--easing-standard),
    box-shadow 180ms var(--easing-standard),
    filter 180ms var(--easing-standard);
}

.ui-btn:hover {
  transform: translateY(-2px);
}

.ui-btn:active {
  transform: translateY(1px) scale(0.985);
}

.ui-btn:disabled {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.48;
}

.ui-btn--iridescent {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.22), transparent 38%),
    linear-gradient(135deg, #6878ff 0%, #8065e9 44%, #42c7d8 100%);
  box-shadow:
    0 10px 28px rgba(91, 107, 255, 0.28),
    inset 0 1px rgba(255, 255, 255, 0.48);
  color: white;
}

.ui-btn--iridescent::after {
  position: absolute;
  z-index: -1;
  top: -80%;
  left: -45%;
  width: 34%;
  height: 260%;
  background: rgba(255, 255, 255, 0.28);
  content: "";
  filter: blur(8px);
  transform: rotate(22deg);
  transition: left 360ms ease;
}

.ui-btn--iridescent:hover::after {
  left: 120%;
}

.ui-btn--pebble {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 48% 52% 46% 54% / 56% 43% 57% 44%;
  background: linear-gradient(145deg, #f4f1e9, #bfc3ca);
  box-shadow:
    inset 4px 5px 7px rgba(255, 255, 255, 0.7),
    inset -5px -6px 9px rgba(36, 39, 52, 0.25),
    0 8px 18px rgba(0, 0, 0, 0.28);
  color: #171922;
}

.ui-btn--carbon {
  border: 1px solid #3b3f4b;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 2px, transparent 2px 6px),
    linear-gradient(#222631, #101117);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.12),
    inset 0 -3px rgba(0, 0, 0, 0.55),
    0 0 0 3px #0b0c10,
    0 8px 22px rgba(0, 0, 0, 0.38);
  letter-spacing: 0.03em;
}

.ui-btn--key {
  border: 1px solid #424654;
  border-radius: 9px;
  background: linear-gradient(180deg, #2b2e38, #171920);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.14),
    0 5px 0 #090a0e,
    0 8px 18px rgba(0, 0, 0, 0.48);
}

.ui-btn--key span {
  color: var(--color-info);
  text-shadow: 0 0 9px rgba(61, 215, 229, 0.8);
}

.ui-btn--key:active {
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 1px 0 #090a0e;
  transform: translateY(4px);
}

.ui-btn--liquid {
  border: 1px solid rgba(61, 215, 229, 0.32);
  background: #101720;
  box-shadow: inset 0 0 0 1px rgba(61, 215, 229, 0.08);
}

.ui-btn--liquid::before {
  position: absolute;
  z-index: -1;
  right: -15%;
  bottom: -90%;
  width: 130%;
  height: 150%;
  border-radius: 45%;
  background: linear-gradient(90deg, #5267ff, #24c9bf);
  content: "";
  transition: transform 360ms ease;
  transform: rotate(8deg);
}

.ui-btn--liquid:hover::before {
  transform: translateY(-46%) rotate(-4deg);
}

.ui-btn--icon-glow {
  width: 46px;
  padding: 0;
  border: 1px solid rgba(120, 134, 255, 0.38);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3f4d88, #151722 68%);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.2),
    0 0 18px rgba(91, 107, 255, 0.24);
  color: #bfc5ff;
  font-size: 20px;
}

.ui-btn--glass,
.ui-btn--soft {
  border: 1px solid var(--color-border-strong);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
}

.ui-btn--soft {
  border-color: rgba(91, 107, 255, 0.2);
  background: var(--color-primary-soft);
  color: #bdc3ff;
}

.ui-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
}

.library-tabs {
  position: sticky;
  z-index: 10;
  top: 88px;
  display: flex;
  gap: 6px;
  margin-bottom: var(--space-10);
  padding: 7px;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: rgba(20, 21, 28, 0.9);
  backdrop-filter: blur(16px);
}

.library-tabs a {
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.library-tabs a:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
}

.library-section {
  margin: 0 0 var(--space-16);
  scroll-margin-top: 150px;
}

.library-heading {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.library-heading > span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 13px;
  color: var(--color-primary-hover);
  font-family: var(--font-mono);
  font-size: 12px;
}

.library-heading h2,
.library-heading p {
  margin: 0;
}

.library-heading h2 {
  font-size: 21px;
}

.library-heading p {
  color: var(--color-text-secondary);
  font-size: 13px;
}

.showcase-grid {
  display: grid;
  gap: var(--space-4);
}

.showcase-grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.showcase-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.showcase-card,
.chart-card,
.ui-glass-card,
.ui-gradient-panel,
.ui-ticket,
.ui-voice-card,
.ui-data-list {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.showcase-card {
  display: grid;
  min-height: 150px;
  place-items: center;
  align-content: center;
  gap: var(--space-4);
  padding: var(--space-6);
}

.showcase-label {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.ui-glass-card {
  position: relative;
  display: grid;
  min-height: 220px;
  align-content: end;
  padding: var(--space-6);
  overflow: hidden;
  background:
    radial-gradient(circle at 80% 10%, rgba(91, 107, 255, 0.28), transparent 36%),
    linear-gradient(150deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.015)),
    #14151c;
  backdrop-filter: blur(18px);
}

.ui-glass-card::before {
  position: absolute;
  top: -40px;
  right: -25px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 46% 54% 65% 35%;
  background: rgba(255, 255, 255, 0.025);
  content: "";
  transform: rotate(24deg);
}

.ui-glass-card .badge {
  position: absolute;
  top: 20px;
  left: 20px;
}

.ui-glass-card > strong {
  font-family: var(--font-mono);
  font-size: 52px;
  line-height: 1;
}

.ui-glass-card > p {
  margin: 5px 0 22px;
  color: var(--color-text-secondary);
}

.mini-spark {
  display: flex;
  height: 36px;
  align-items: end;
  gap: 7px;
}

.mini-spark i {
  width: 100%;
  height: 35%;
  border-radius: 4px 4px 1px 1px;
  background: linear-gradient(#7886ff, #4656dd);
}

.mini-spark i:nth-child(2) { height: 55%; }
.mini-spark i:nth-child(3) { height: 42%; }
.mini-spark i:nth-child(4) { height: 72%; }
.mini-spark i:nth-child(5) { height: 60%; }
.mini-spark i:nth-child(6) { height: 92%; }
.mini-spark i:nth-child(7) { height: 80%; }

.ui-gradient-panel {
  display: flex;
  min-height: 220px;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-6);
  background:
    radial-gradient(circle at 18% 20%, rgba(61, 215, 229, 0.18), transparent 34%),
    radial-gradient(circle at 90% 70%, rgba(91, 107, 255, 0.26), transparent 42%),
    rgba(255, 255, 255, 0.025);
}

.ui-gradient-panel strong,
.ui-ticket strong,
.ui-voice-card strong,
.battery-demo strong {
  display: block;
  margin-top: 7px;
  font-size: 22px;
}

.ui-counter {
  display: flex;
  align-items: center;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  background: rgba(10, 11, 15, 0.42);
}

.ui-counter button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: white;
}

.ui-counter span {
  padding: 0 12px;
  color: var(--color-text-secondary);
  font-size: 12px;
}

.ui-ticket {
  display: grid;
  min-height: 220px;
  grid-template-columns: minmax(0, 1fr) 120px;
  align-items: center;
  padding: var(--space-6);
  overflow: hidden;
  background:
    radial-gradient(circle at 75% 20%, rgba(245, 213, 71, 0.14), transparent 34%),
    var(--color-surface);
}

.ui-ticket > div {
  display: grid;
}

.ui-ticket small,
.ui-voice-card small {
  margin-top: 6px;
  color: var(--color-text-secondary);
}

.ticket-code {
  align-self: stretch;
  display: grid;
  place-items: center;
  border-left: 1px dashed var(--color-border-strong);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  letter-spacing: 2px;
  writing-mode: vertical-rl;
}

.ui-voice-card {
  display: grid;
  min-height: 220px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-6);
}

.ui-orb,
.empty-orb {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #e1e4ff 0 4%, #8f9cff 22%, #3442c9 54%, #101326 72%);
  box-shadow:
    0 0 22px rgba(91, 107, 255, 0.46),
    inset -9px -10px 18px rgba(0, 0, 0, 0.48);
}

.ui-orb span,
.empty-orb span {
  width: 36%;
  height: 36%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
}

.chart-card {
  min-height: 240px;
  padding: var(--space-6);
}

.chart-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.chart-card-head strong {
  display: block;
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 26px;
}

.chart-card-head small {
  color: var(--color-text-secondary);
}

.line-chart {
  width: 100%;
  margin-top: 24px;
  overflow: visible;
}

.line-chart-fill {
  fill: url("#line-fill");
}

.line-chart-line {
  fill: none;
  stroke: #7886ff;
  stroke-linecap: round;
  stroke-width: 4;
  filter: drop-shadow(0 0 7px rgba(120, 134, 255, 0.55));
}

.bar-chart {
  display: flex;
  height: 150px;
  align-items: end;
  justify-content: space-around;
  gap: var(--space-3);
  margin-top: 18px;
  padding-top: 12px;
  border-bottom: 1px solid var(--color-border);
  background: repeating-linear-gradient(0deg, transparent 0 37px, rgba(255, 255, 255, 0.035) 37px 38px);
}

.bar-chart > span {
  position: relative;
  width: min(46px, 18%);
  height: calc(var(--bar) * 1%);
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, #7886ff, #313d9f);
  box-shadow: inset 1px 0 rgba(255, 255, 255, 0.16);
}

.bar-chart > span:nth-child(2) {
  background: linear-gradient(180deg, #3dd7e5, #1b7480);
}

.bar-chart > span:nth-child(3) {
  background: linear-gradient(180deg, #2be08c, #12784a);
}

.bar-chart > span:nth-child(4) {
  background: linear-gradient(180deg, #f5d547, #826e15);
}

.bar-chart i {
  position: absolute;
  right: 50%;
  bottom: -25px;
  color: var(--color-text-muted);
  font-size: 10px;
  font-style: normal;
  transform: translateX(50%);
  white-space: nowrap;
}

.progress-demo {
  display: grid;
  align-content: center;
}

.ui-progress {
  height: 14px;
  margin-top: 26px;
  padding: 3px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  background: #0c0d12;
}

.ui-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #5869ff, #3dd7e5);
  box-shadow: 0 0 12px rgba(61, 215, 229, 0.36);
}

.battery-demo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
}

.ui-battery {
  position: relative;
  width: 150px;
  height: 76px;
  padding: 7px;
  border: 3px solid #626876;
  border-radius: 15px;
  background: #0c0d12;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.7);
}

.ui-battery::after {
  position: absolute;
  top: 22px;
  right: -12px;
  width: 9px;
  height: 28px;
  border-radius: 0 5px 5px 0;
  background: #626876;
  content: "";
}

.ui-battery span {
  display: block;
  height: 100%;
  border-radius: 8px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 18px, transparent 18px 22px),
    linear-gradient(90deg, #2be08c, #62f6b5);
  box-shadow: 0 0 14px rgba(43, 224, 140, 0.38);
}

.ui-search {
  display: grid;
  width: min(520px, 100%);
  min-height: 54px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: 7px 9px 7px 16px;
  border: 1px solid var(--color-border-strong);
  border-radius: 16px;
  background:
    linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
    linear-gradient(100deg, #5b6bff, #3dd7e5) border-box;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.ui-search:focus-within {
  box-shadow: var(--focus-ring), 0 12px 32px rgba(0, 0, 0, 0.28);
}

.ui-search input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--color-text-primary);
}

.ui-search kbd {
  padding: 5px 8px;
  border: 1px solid var(--color-border-strong);
  border-radius: 8px;
  background: var(--color-elevated);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.ui-segmented {
  display: flex;
  width: min(520px, 100%);
  margin: 0;
  padding: 5px;
  border: 1px solid var(--color-border);
  border-radius: 15px;
  background: #0e0f14;
}

.ui-segmented label {
  flex: 1;
  cursor: pointer;
}

.ui-segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ui-segmented span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--color-text-secondary);
  font-size: 13px;
}

.ui-segmented input:checked + span {
  border-color: rgba(120, 134, 255, 0.28);
  background: var(--color-primary-soft);
  color: #cdd1ff;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
}

.ui-segmented input:focus-visible + span {
  box-shadow: var(--focus-ring);
}

.tooltip-demo {
  position: relative;
  display: inline-grid;
  justify-items: center;
}

.ui-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: 220px;
  padding: 8px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: 9px;
  background: #292c37;
  box-shadow: var(--shadow-md);
  color: var(--color-text-primary);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.tooltip-demo:hover .ui-tooltip,
.tooltip-demo:focus-within .ui-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.ui-data-list {
  display: grid;
  overflow: hidden;
}

.ui-data-list > div {
  display: grid;
  min-height: 74px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
}

.ui-data-list > div:first-child {
  border-top: 0;
}

.ui-data-list strong,
.ui-data-list small {
  display: block;
}

.ui-data-list small {
  margin-top: 3px;
  color: var(--color-text-secondary);
}

.file-glyph {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 11px;
  background: var(--color-danger-soft);
  color: #ff8298;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 800;
}

.file-glyph.is-image {
  background: var(--color-info-soft);
  color: var(--color-info);
}

.library-note {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: 12px;
}

.library-note > span {
  padding: 5px 8px;
  border: 1px solid var(--color-border-strong);
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
}

.library-note p {
  margin: 0;
}

@media (max-width: 1000px) {
  .showcase-grid--three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .library-tabs {
    top: 72px;
  }

  .showcase-grid--three,
  .showcase-grid--two {
    grid-template-columns: 1fr;
  }

  .ui-gradient-panel,
  .battery-demo {
    align-items: flex-start;
    flex-direction: column;
  }

  .ui-ticket {
    grid-template-columns: minmax(0, 1fr) 70px;
  }

  .ui-voice-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .ui-voice-card > .ui-btn {
    grid-column: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ui-btn--iridescent::after,
  .ui-btn--liquid::before {
    transition: none;
  }
}
