/* Link Generator — modern glass UI. Theme-aware, no external deps. */

:root {
  --bg: #f4f6fb;
  --surface: rgba(255, 255, 255, .72);
  --surface-solid: #ffffff;
  --surface-2: rgba(241, 244, 250, .85);
  --fg: #0f172a;
  --muted: #5b6478;
  --faint: #8a93a6;
  --line: rgba(15, 23, 42, .09);
  --line-2: rgba(15, 23, 42, .06);
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-3: #d946ef;
  --accent-fg: #ffffff;
  --accent-soft: rgba(99, 102, 241, .14);
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #c026d3 110%);
  --danger: #e11d48;
  --warn: #a16207;
  --warn-bg: rgba(254, 249, 195, .6);
  --warn-line: rgba(161, 98, 7, .25);
  --radius: 20px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 16px 40px -16px rgba(15, 23, 42, .14);
  --shadow-accent: 0 8px 24px -8px rgba(124, 58, 237, .5);
  --ring: 0 0 0 3px var(--accent-soft);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0d14;
    --surface: rgba(19, 25, 38, .66);
    --surface-solid: #1a2233;
    --surface-2: rgba(15, 21, 33, .85);
    --fg: #e8edf6;
    --muted: #98a2b6;
    --faint: #67718a;
    --line: rgba(255, 255, 255, .09);
    --line-2: rgba(255, 255, 255, .06);
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --accent-3: #e879f9;
    --accent-soft: rgba(129, 140, 248, .16);
    --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #d946ef 110%);
    --danger: #fb7185;
    --warn: #facc15;
    --warn-bg: rgba(113, 63, 18, .35);
    --warn-line: rgba(250, 204, 21, .25);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -16px rgba(0, 0, 0, .6);
    --shadow-accent: 0 8px 24px -8px rgba(139, 92, 246, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

/* ambient gradient mesh */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(640px 420px at 12% 6%, var(--accent-soft), transparent 65%),
    radial-gradient(720px 520px at 88% 14%, color-mix(in srgb, var(--accent-3) 14%, transparent), transparent 60%),
    radial-gradient(680px 620px at 50% 105%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%);
}

.shell {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: calc(32px + env(safe-area-inset-top, 0px)) calc(40px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.head, .card, .foot { animation: rise .5s cubic-bezier(.2, .7, .3, 1) both; }
.card.result { animation-delay: 0ms; }
form.card { animation-delay: 70ms; }
.foot { animation-delay: 140ms; }

/* ---- header ---- */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(24px, 6vw, 30px);
  font-weight: 800;
  letter-spacing: -.02em;
  text-wrap: balance;
}
.logo {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--grad);
  box-shadow: var(--shadow-accent);
  color: #fff;
}
.logo svg { width: 22px; height: 22px; }

/* ---- cards (glass) ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .field-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
}

input#domain {
  width: 100%;
  font: inherit;
  font-size: 16px;
  color: var(--fg);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 13px;
  padding: 13px 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input#domain::placeholder { color: var(--faint); }
input#domain:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input#domain.invalid { border-color: var(--danger); }

.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.hint.error { color: var(--danger); }

/* ---- segmented control (Sumber) ---- */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.seg {
  flex: 1 1 0;
  font: inherit;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
  touch-action: manipulation;
}
.seg svg { width: 16px; height: 16px; }
.seg[aria-pressed="true"] {
  background: var(--surface-solid);
  color: var(--fg);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 4px 12px -4px rgba(15, 23, 42, .12);
}

/* ---- manual input textarea ---- */
.optional { font-weight: 500; text-transform: none; letter-spacing: 0; }
.manual-box {
  width: 100%;
  min-height: 110px;
  max-height: 260px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 13px;
  padding: 12px 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.manual-box::placeholder { color: var(--faint); }
.manual-box:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.seg:focus-visible, .generate:focus-visible, .copy-all:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- primary action ---- */
.generate {
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 14px;
  padding: 15px 16px;
  background: var(--grad);
  background-size: 140% 140%;
  color: #fff;
  box-shadow: var(--shadow-accent);
  transition: background-position .25s ease, transform .06s ease, box-shadow .2s ease, opacity .15s ease;
  touch-action: manipulation;
}
.generate svg { width: 18px; height: 18px; }
.generate:hover { background-position: 90% 50%; box-shadow: 0 12px 30px -8px rgba(124, 58, 237, .55); }
.generate:active { transform: scale(.98); }
.generate[disabled] { opacity: .75; cursor: progress; }

@keyframes spin { to { transform: rotate(360deg); } }
.generate .spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}

.form-error {
  margin: 0;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 14px;
}

/* ---- result ---- */
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.result-summary {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-wrap: balance;
}
.result-summary svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.copy-all {
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  color: var(--fg);
  border-radius: 10px;
  padding: 8px 13px;
  white-space: nowrap;
  transition: border-color .15s ease, color .15s ease;
  touch-action: manipulation;
}
.copy-all svg { width: 14px; height: 14px; }
.copy-all:hover { border-color: var(--accent); color: var(--accent); }

.warn {
  margin: 0;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 13.5px;
}

.links-box {
  width: 100%;
  min-height: 150px;
  max-height: 320px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px;
  white-space: pre;
  overflow: auto;
}
.links-box:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

/* ---- misc ---- */
.foot { text-align: center; color: var(--faint); font-size: 12.5px; text-wrap: pretty; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: color-mix(in srgb, var(--fg) 92%, transparent);
  color: var(--bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 50;
  animation: toast-in .25s cubic-bezier(.2, .7, .3, 1) both;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

@media (hover: hover) and (pointer: fine) {
  html { overscroll-behavior: none; }
}

@media (max-width: 480px) {
  .seg { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
