/* =========================================================
   Rut Gon Link — Stylesheet
   Author: trongsigma | AI assistant: Claude (Anthropic)
   ========================================================= */

/* ---------- Design tokens ---------- */
:root {
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, sans-serif;

  --grad-start: #14B8A6;
  --grad-end: #7C3AED;

  --color-primary: #0D9488;
  --color-primary-hover: #0B8377;
  --color-primary-contrast: #ffffff;
  --color-secondary: #7C3AED;

  --color-danger: #DC2626;
  --color-success: #16A34A;

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .14), 0 4px 10px rgba(15, 23, 42, .08);

  --transition-fast: 140ms cubic-bezier(.4,0,.2,1);
  --transition-med: 240ms cubic-bezier(.4,0,.2,1);

  --max-width: 1080px;

  /* Light theme surfaces (default) */
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-alt: #F1F5F9;
  --surface-hover: #EAEFF5;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-muted: #57657A;
  --text-faint: #94A3B8;
  --overlay: rgba(15, 23, 42, .5);
}

[data-theme="dark"] {
  --bg: #0B1220;
  --surface: #121B2C;
  --surface-alt: #182338;
  --surface-hover: #1F2C44;
  --border: #263349;
  --text: #E7EBF3;
  --text-muted: #97A3B8;
  --text-faint: #6B7891;
  --overlay: rgba(0, 0, 0, .6);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition-med), color var(--transition-med);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.material-symbols-rounded {
  font-variation-settings: 'FILL' 0, 'wght' 450, 'GRAD' 0, 'opsz' 24;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
}

a { color: inherit; }
button { font-family: inherit; }

.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--max-width); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { display: inline-flex; border-radius: 10px; overflow: hidden; }
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; color: var(--text); }
.brand-accent { color: var(--color-primary); }

.header-actions { display: flex; align-items: center; gap: 8px; }
.control-group { position: relative; }

.pill-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-alt); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 14px; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: background var(--transition-fast), transform var(--transition-fast);
}
.pill-btn:hover { background: var(--surface-hover); }
.pill-btn:active { transform: scale(.96); }
.pill-btn .material-symbols-rounded { font-size: 18px; }

.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  list-style: none; margin: 0; padding: 6px; min-width: 168px; z-index: 50;
}
.dropdown[hidden] { display: none; }
.dropdown li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-xs);
  font-size: .88rem; font-weight: 500; cursor: pointer;
  color: var(--text); transition: background var(--transition-fast);
}
.dropdown li:hover { background: var(--surface-alt); }
.dropdown li[aria-selected="true"] { color: var(--color-primary); font-weight: 700; }
.flag-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--surface-alt); font-size: .62rem; font-weight: 800;
  letter-spacing: .02em;
}

/* ---------- Hero ---------- */
.hero { padding: 56px 20px 24px; }
.hero-inner { max-width: 720px; margin: 0 auto; text-align: center; }

.eyebrow {
  display: inline-block; font-size: .78rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  padding: 6px 14px; border-radius: var(--radius-pill); margin: 0 0 18px;
}

.hero-title {
  font-size: clamp(2rem, 5.4vw, 3.1rem);
  font-weight: 800; letter-spacing: -.02em; line-height: 1.12;
  margin: 0 0 14px;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .12em;
}
.squeeze-wrap {
  display: inline-flex; align-items: center; position: relative;
  width: 1.05em; height: 1em; vertical-align: middle;
}
.squeeze-chevron {
  position: absolute; top: 50%; font-size: .8em;
  color: var(--color-secondary);
  animation: squeezeIn 2.6s ease-in-out infinite;
}
.squeeze-left { left: -0.15em; transform: translateY(-50%); animation-delay: 0s; }
.squeeze-right { right: -0.15em; transform: translateY(-50%) rotate(0deg); animation-delay: 0s; }
@keyframes squeezeIn {
  0%, 100% { opacity: .35; }
  50% { opacity: 1; }
}
.squeeze-left { animation-name: squeezeInLeft; }
.squeeze-right { animation-name: squeezeInRight; }
@keyframes squeezeInLeft {
  0%, 100% { transform: translate(0, -50%); opacity: .4; }
  50% { transform: translate(6px, -50%); opacity: 1; }
}
@keyframes squeezeInRight {
  0%, 100% { transform: translate(0, -50%); opacity: .4; }
  50% { transform: translate(-6px, -50%); opacity: 1; }
}

.hero-sub { color: var(--text-muted); font-size: 1.05rem; margin: 0 0 32px; }

/* ---------- Shorten form ---------- */
.shorten-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-md); text-align: left;
}

.field-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-alt); border: 1.5px solid transparent;
  border-radius: var(--radius-md); padding: 4px 6px 4px 16px;
  transition: border-color var(--transition-fast);
}
.field-row:focus-within { border-color: var(--color-primary); }
.field-row.small { padding: 2px 4px 2px 12px; border-radius: var(--radius-sm); }
.field-icon { color: var(--text-faint); flex-shrink: 0; }
.field-row input {
  flex: 1; border: none; background: transparent; outline: none;
  font-family: inherit; font-size: 1rem; color: var(--text);
  padding: 14px 4px; min-width: 0;
}
.field-row.small input { padding: 10px 4px; font-size: .92rem; }
.field-row input::placeholder { color: var(--text-faint); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer; flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.ghost { background: transparent; border-color: transparent; }

.advanced-toggle {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: var(--text-muted);
  font-size: .85rem; font-weight: 600; cursor: pointer;
  padding: 12px 4px 4px; width: 100%;
}
.advanced-toggle .chevron { margin-left: auto; transition: transform var(--transition-fast); }
.advanced-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.advanced-toggle:hover { color: var(--text); }

.advanced-panel { padding: 12px 4px 4px; animation: fadeSlide var(--transition-med); }
.advanced-panel[hidden] { display: none; }
.field-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.field-hint { font-size: .78rem; color: var(--text-faint); margin: 8px 2px 0; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.btn-primary {
  position: relative; width: 100%; margin-top: 16px;
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  color: #fff; border: none; border-radius: var(--radius-md);
  padding: 15px 20px; font-size: 1rem; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .75; cursor: default; transform: none; }
.btn-content { display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary.is-loading .btn-content { visibility: hidden; }
.btn-spinner { display: none; }
.btn-primary.is-loading .btn-spinner {
  display: block; position: absolute; inset: 0; margin: auto;
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-secondary {
  background: var(--surface-alt); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 10px 18px; font-weight: 700;
  font-size: .88rem; cursor: pointer; transition: background var(--transition-fast);
}
.btn-secondary:hover { background: var(--surface-hover); }
.btn-secondary.small { padding: 8px 14px; font-size: .82rem; }

/* ---------- Result card ---------- */
.result-card {
  margin-top: 18px; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px; animation: fadeSlide var(--transition-med);
}
.result-card[hidden] { display: none; }
.result-row { display: flex; align-items: center; gap: 10px; }
.result-check { color: var(--color-success); flex-shrink: 0; }
.result-link {
  flex: 1; font-weight: 700; font-size: 1.02rem; text-decoration: none;
  color: var(--color-primary); word-break: break-all;
}
.result-link:hover { text-decoration: underline; }
.result-buttons { display: flex; gap: 6px; flex-shrink: 0; }
.result-original {
  margin: 10px 0 0; font-size: .82rem; color: var(--text-faint);
  word-break: break-all;
}
.qr-wrap { display: flex; justify-content: center; margin-top: 14px; }
.qr-wrap[hidden] { display: none; }
.qr-wrap canvas { border-radius: var(--radius-sm); background: #fff; padding: 10px; box-shadow: var(--shadow-sm); }

.error-msg {
  margin-top: 14px; color: var(--color-danger); font-weight: 600; font-size: .9rem;
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
  border-radius: var(--radius-sm); padding: 10px 14px;
}
.error-msg[hidden] { display: none; }

/* ---------- Sections shared ---------- */
.section-inner { max-width: var(--max-width); margin: 0 auto; padding: 64px 20px; }
.section-title { font-size: clamp(1.4rem, 3vw, 1.9rem); font-weight: 800; letter-spacing: -.01em; margin: 0 0 32px; text-align: center; }
.section-title.no-margin { margin: 0; text-align: left; }

/* ---------- Features ---------- */
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 24px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.feature-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--color-primary) 14%, transparent);
  color: var(--color-primary); margin-bottom: 14px; font-size: 24px;
}
.feature-card h3 { margin: 0 0 8px; font-size: 1.02rem; font-weight: 700; }
.feature-card p { margin: 0; font-size: .9rem; color: var(--text-muted); line-height: 1.5; }

/* ---------- History ---------- */
.history-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.history-actions { display: flex; gap: 8px; }
.text-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--text-muted);
  font-weight: 600; font-size: .84rem; cursor: pointer; padding: 6px 8px;
  border-radius: var(--radius-xs); transition: background var(--transition-fast), color var(--transition-fast);
}
.text-btn:hover { background: var(--surface-alt); color: var(--text); }
.text-btn.danger:hover { color: var(--color-danger); }

.history-stats { display: flex; gap: 12px; margin-bottom: 20px; }
.stat-chip {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
}
.stat-chip .stat-value { font-size: 1.5rem; font-weight: 800; display: block; }
.stat-chip .stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 600; }

.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  animation: fadeSlide var(--transition-med);
}
.history-item-icon {
  width: 38px; height: 38px; border-radius: var(--radius-xs); flex-shrink: 0;
  background: color-mix(in srgb, var(--color-secondary) 14%, transparent);
  color: var(--color-secondary); display: flex; align-items: center; justify-content: center;
}
.history-item-main { flex: 1; min-width: 0; }
.history-item-short { font-weight: 700; color: var(--color-primary); text-decoration: none; font-size: .95rem; }
.history-item-short:hover { text-decoration: underline; }
.history-item-orig {
  margin: 3px 0 0; font-size: .8rem; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-item-meta { font-size: .72rem; color: var(--text-faint); margin-top: 4px; }
.history-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.history-item-actions .icon-btn { width: 34px; height: 34px; }
.history-item-actions .icon-btn .material-symbols-rounded { font-size: 18px; }

.empty-state {
  display: none; flex-direction: column; align-items: center; text-align: center;
  padding: 48px 20px; color: var(--text-faint);
}
.empty-state.visible { display: flex; }
.empty-state .material-symbols-rounded { font-size: 40px; margin-bottom: 12px; }
.empty-state p { margin: 0; max-width: 320px; }

/* ---------- How it works ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 20px; max-width: 620px; margin-inline: auto; }
.step { display: flex; gap: 16px; align-items: flex-start; }
.step-num {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center;
  font-size: .95rem;
}
.step h3 { margin: 4px 0 6px; font-size: 1rem; font-weight: 700; }
.step p { margin: 0; color: var(--text-muted); font-size: .92rem; line-height: 1.5; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: auto; }
.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 28px 20px; text-align: center; }
.footer-line { margin: 0 0 6px; font-size: .88rem; color: var(--text-muted); }
.footer-line strong { color: var(--text); }
.footer-sub { margin: 0; font-size: .78rem; color: var(--text-faint); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg);
  padding: 12px 20px; border-radius: var(--radius-pill);
  font-size: .88rem; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity var(--transition-med), transform var(--transition-med);
  z-index: 100; max-width: 90vw; text-align: center;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Install banner ---------- */
.install-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 90;
  max-width: 480px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px; box-shadow: var(--shadow-lg);
}
.install-banner[hidden] { display: none; }
.install-banner .material-symbols-rounded { color: var(--color-primary); flex-shrink: 0; }
.install-banner p { flex: 1; margin: 0; font-size: .84rem; color: var(--text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .header-inner { padding: 10px 14px; }
  .brand-name { font-size: .95rem; }
  .pill-btn span:not(.material-symbols-rounded) { display: none; }
  .pill-btn { padding: 9px; }
  .hero { padding: 36px 14px 16px; }
  .hero-title { font-size: clamp(1.7rem, 8vw, 2.2rem); }
  .hero-sub { font-size: .95rem; margin-bottom: 24px; }
  .shorten-card { padding: 16px; border-radius: var(--radius-md); }
  .section-inner { padding: 44px 16px; }
  .feature-grid { grid-template-columns: 1fr; }
  .history-header { flex-direction: column; align-items: flex-start; }
  .history-stats { flex-direction: column; }
  .result-row { flex-wrap: wrap; }
  .result-buttons { width: 100%; justify-content: flex-end; }
  .install-banner { flex-wrap: wrap; }
}

@media (max-width: 380px) {
  .field-row { padding-left: 12px; }
  .field-row input { font-size: .92rem; }
}

/* Focus visibility for accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
