/* ============================================================
   SentSystem — premium UI (light, glassmorphism, gradient glow)
   Inter (Latin) + IBM Plex Sans Thai (Thai) + JetBrains Mono (labels)
   ============================================================ */
:root {
  /* brand */
  --primary: #F97316;
  --primary-deep: #EA580C;
  --primary-deeper: #C2410C;
  --accent-cool: #6366F1;

  /* surfaces / text */
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #F3F4F6;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(17, 24, 39, 0.08);
  --text: #0F1115;
  --text-soft: #3F434D;
  --muted: #71757F;
  --border: rgba(17, 24, 39, 0.09);

  /* gradients */
  --grad-primary: linear-gradient(135deg, #FB923C 0%, #EA580C 100%);
  --grad-text: linear-gradient(120deg, #F97316 0%, #C2410C 100%);

  /* shadows (layered for depth) */
  --shadow-sm: 0 1px 2px rgba(16, 17, 21, .05), 0 1px 1px rgba(16, 17, 21, .03);
  --shadow-md: 0 6px 16px rgba(16, 17, 21, .07), 0 2px 6px rgba(16, 17, 21, .04);
  --shadow-lg: 0 18px 40px rgba(16, 17, 21, .12), 0 6px 14px rgba(16, 17, 21, .06);
  --shadow-glow: 0 10px 30px rgba(234, 88, 12, .32);

  /* type */
  --font-display: "Inter", "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-body: "Inter", "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Sans Thai", ui-monospace, monospace;

  /* radius */
  --r-card: 18px;
  --r-control: 12px;
  --r-pill: 9999px;

  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* Ambient gradient-mesh background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(55vw 55vw at 88% -12%, rgba(249, 115, 22, .12), transparent 60%),
    radial-gradient(48vw 48vw at -8% 6%, rgba(99, 102, 241, .07), transparent 58%),
    radial-gradient(42vw 42vw at 50% 118%, rgba(234, 88, 12, .06), transparent 60%);
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

a { color: var(--primary-deep); }

/* ---------------- Header (sticky glass) ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--glass-border);
  padding: 18px 0;
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  width: 30px; height: 30px; flex: none; display: block;
  filter: drop-shadow(0 4px 10px rgba(234, 88, 12, .28));
}
.plain-link { color: inherit; text-decoration: none; }

.total-badge {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 8px 18px;
  border-radius: var(--r-control);
  background: rgba(255, 255, 255, .7);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.total-num {
  font-family: var(--font-display);
  font-size: 1.6rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em;
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.total-label { font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin-top: 3px; }

main { padding: 56px 0 64px; min-height: 60vh; }
.muted { color: var(--muted); }

/* ---------------- Landing (hero) ---------------- */
.landing { max-width: 720px; margin: 0 auto; animation: rise .6s var(--ease) both; }
.landing-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800; line-height: 1.05; letter-spacing: -0.035em;
  margin: 0 0 22px;
  background: linear-gradient(120deg, #18181B 0%, #18181B 40%, #EA580C 110%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.landing-text { font-size: 1.05rem; line-height: 1.85; color: var(--text-soft); margin: 0 0 18px; }
.landing-note {
  margin-top: 28px;
  background: rgba(255, 255, 255, .65);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 18px 22px;
  font-family: var(--font-display); font-weight: 500;
  box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
}
.landing-note::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--grad-primary);
}

/* ---------------- File grid ---------------- */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.file-card {
  display: block; padding: 22px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); text-decoration: none; color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s var(--ease);
  animation: rise .5s var(--ease) both;
}
.file-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); border-color: rgba(249, 115, 22, .4); }
.file-name { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; letter-spacing: -0.02em; word-break: break-word; }
.file-note { color: var(--muted); font-size: .9rem; margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.file-meta { display: flex; justify-content: space-between; margin-top: 18px; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.dl-count { color: var(--primary-deep); font-weight: 600; }

/* ---------------- File detail ---------------- */
.back-link { font-family: var(--font-mono); font-size: 12px; color: var(--primary-deep); text-decoration: none; }
.file-detail {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: clamp(24px, 5vw, 48px);
  box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
  animation: rise .55s var(--ease) both;
}
.file-detail::before {
  content: ""; position: absolute; top: -40%; right: -20%; width: 50%; height: 80%;
  background: radial-gradient(circle, rgba(249, 115, 22, .12), transparent 70%);
  pointer-events: none;
}
/* poster (left) + download (right) layout */
.detail-layout { position: relative; }
.detail-layout.has-poster { display: flex; gap: 36px; align-items: flex-start; }
.detail-poster { flex: 0 0 42%; max-width: 440px; }
.detail-poster img {
  width: 100%; height: auto; display: block; border-radius: var(--r-control);
  border: 1px solid var(--border); box-shadow: var(--shadow-md); background: var(--surface-2);
}
.detail-main { flex: 1; min-width: 0; }
@media (max-width: 760px) {
  .detail-layout.has-poster { flex-direction: column; gap: 24px; }
  .detail-poster { flex: none; max-width: 100%; width: 100%; }
}

/* full-width Tech Stack image below the layout */
.detail-techstack { margin-top: 36px; padding-top: 30px; border-top: 1px solid var(--border); position: relative; }
.techstack-label {
  font-family: var(--font-mono); font-size: 11px; color: var(--primary-deep);
  text-transform: uppercase; letter-spacing: .12em; margin-bottom: 14px;
}
.detail-techstack img {
  width: 100%; height: auto; display: block; border-radius: var(--r-control);
  border: 1px solid var(--border); box-shadow: var(--shadow-md); background: var(--surface-2);
}

.detail-name {
  font-family: var(--font-display);
  margin: 0 0 28px; font-size: clamp(1.5rem, 4vw, 2.3rem);
  font-weight: 800; line-height: 1.1; letter-spacing: -0.03em; word-break: break-word;
  position: relative;
}
.detail-stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 30px; position: relative; }
.stat {
  flex: 1; min-width: 130px;
  background: linear-gradient(180deg, rgba(255,255,255,.9), var(--surface-2));
  border: 1px solid var(--border); border-radius: var(--r-control);
  padding: 20px 16px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-num {
  font-family: var(--font-display);
  font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1;
  background: var(--grad-text);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.stat-label { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; margin-top: 7px; }

.detail-note {
  background: linear-gradient(135deg, rgba(249,115,22,.06), rgba(99,102,241,.04));
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  padding: 18px 22px; margin-bottom: 30px; position: relative;
}
.note-label { font-family: var(--font-mono); font-size: 10.5px; color: var(--primary-deep); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.detail-note p { margin: 0; white-space: pre-wrap; color: var(--text-soft); }

.detail-date { margin-top: 18px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ---------------- Download / manual buttons ---------------- */
.dl-center { text-align: center; position: relative; }
.download-btn {
  display: inline-block; border: none; cursor: pointer; margin: 6px;
  padding: 15px 38px; border-radius: var(--r-pill);
  background: var(--grad-primary); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em;
  text-decoration: none;
  box-shadow: var(--shadow-glow);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), filter .25s var(--ease);
}
.download-btn:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(234,88,12,.42); filter: brightness(1.05); }
.download-btn:active { transform: translateY(-1px); }
.download-btn.secondary {
  background: rgba(255,255,255,.8); color: var(--primary-deep);
  border: 1.5px solid rgba(249,115,22,.5); box-shadow: var(--shadow-sm);
}
.download-btn.secondary:hover { background: var(--grad-primary); color: #fff; border-color: transparent; box-shadow: var(--shadow-glow); }
.download-btn.loading { opacity: .65; cursor: default; transform: none; box-shadow: var(--shadow-sm); }
.download-btn:disabled { cursor: default; }

/* progress */
.dl-prep { margin: 22px auto 0; max-width: 380px; text-align: center; }
.dl-spinner {
  width: 30px; height: 30px; margin: 0 auto 14px;
  border: 3px solid rgba(249,115,22,.18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: dl-spin .8s linear infinite;
}
.dl-status { font-family: var(--font-mono); font-size: 12px; color: var(--primary-deep); margin-bottom: 10px; }
.dl-bar { height: 9px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill); overflow: hidden; }
.dl-bar-fill { height: 100%; width: 0%; background: var(--grad-primary); border-radius: var(--r-pill); box-shadow: 0 0 12px rgba(249,115,22,.5); transition: width .15s linear; }

/* ---------------- Ads ---------------- */
.ad-slot { margin: 28px 0; min-height: 90px; }
.ad-placeholder {
  border: 1px dashed var(--border); border-radius: var(--r-card);
  color: var(--muted); font-family: var(--font-mono); font-size: 12px; letter-spacing: .04em;
  text-align: center; padding: 40px 12px;
  background: rgba(255,255,255,.4);
}

/* ---------------- Footer ---------------- */
.site-footer { border-top: 1px solid var(--border); padding: 32px 0; color: var(--muted); font-family: var(--font-mono); font-size: 12px; text-align: center; }
.site-footer a { color: var(--primary-deep); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ---------------- Donate ---------------- */
.donate-wrap { text-align: center; margin: 10px auto 28px; }
.donate-btn {
  display: inline-block; cursor: pointer;
  background: rgba(255,255,255,.8); color: var(--primary-deep);
  border: 1.5px solid rgba(249,115,22,.45); border-radius: var(--r-pill);
  padding: 11px 24px; font-family: var(--font-display); font-weight: 600; font-size: .95rem;
  box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease), color .25s var(--ease);
}
.donate-btn:hover { background: var(--grad-primary); color: #fff; border-color: transparent; transform: translateY(-2px); box-shadow: var(--shadow-glow); }
/* compact variant for the header */
.donate-btn-top { padding: 8px 16px; font-size: .85rem; }

.donate-modal {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  background: rgba(16, 17, 21, .55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 16px; animation: fade .25s ease both;
}
.donate-modal[hidden] { display: none; }
.donate-card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 32px 26px; max-width: 360px; width: 100%; text-align: center;
  box-shadow: var(--shadow-lg); animation: pop .35s var(--ease) both;
}
.donate-close {
  position: absolute; top: 12px; right: 14px; width: 32px; height: 32px;
  background: var(--surface-2); border: none; border-radius: 50%; color: var(--muted);
  font-size: 1.3rem; line-height: 1; cursor: pointer; transition: background .2s, color .2s;
}
.donate-close:hover { background: #FEE2E2; color: #DC2626; }
.donate-title { font-family: var(--font-display); margin: 0 0 4px; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.donate-sub { font-family: var(--font-mono); font-size: 11.5px; margin: 0 0 18px; color: var(--muted); }
.donate-qr { width: 100%; max-width: 280px; height: auto; border-radius: 14px; background: #fff; padding: 8px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.donate-meta { font-family: var(--font-mono); font-size: 11px; color: var(--muted); margin-top: 12px; letter-spacing: .08em; }
.donate-thanks {
  margin: 18px 0 0; padding-top: 18px; border-top: 1px solid var(--border);
  font-size: .92rem; line-height: 1.75; color: var(--text-soft); text-align: left;
}

/* ---------------- Animations ---------------- */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes dl-spin { to { transform: rotate(360deg); } }

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