/* ============================================================
   TELEPIC — style.css
   A minimal, Telegraph-inspired publishing platform.
   Modern Gen-Z design with smooth animations & responsive layout.
   ============================================================ */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Playfair+Display:wght@400;700;800&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Palette */
  --bg:          #0f0f14;
  --bg-alt:      #16161e;
  --surface:     #1e1e2a;
  --surface-2:   #262636;
  --border:      rgba(255,255,255,.06);
  --border-hover:rgba(255,255,255,.12);
  --border-focus:#6366f1;
  --text:        #f0f0f5;
  --text-muted:  #8b8da3;
  --text-light:  #5a5c73;
  --accent:      #6366f1;
  --accent-hover:#818cf8;
  --accent-soft: rgba(99,102,241,.12);
  --success:     #22c55e;
  --success-soft:rgba(34,197,94,.12);
  --danger:      #ef4444;
  --danger-soft: rgba(239,68,68,.12);

  /* Gradient accents */
  --gradient-accent: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  --gradient-glow:   radial-gradient(circle at 50% 0%, rgba(99,102,241,.12) 0%, transparent 60%);

  /* Typography */
  --font-serif:  'Playfair Display', 'Georgia', serif;
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Sizes */
  --max-w:       728px;
  --radius:      12px;
  --radius-sm:   8px;
  --transition:  .22s cubic-bezier(.4,0,.2,1);
  --spring:      .4s cubic-bezier(.34,1.56,.64,1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-serif);
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ---------- Animated Background ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99,102,241,.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 60%, rgba(168,85,247,.08) 0%, transparent 50%),
    radial-gradient(ellipse 50% 30% at 10% 80%, rgba(236,72,153,.06) 0%, transparent 50%);
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  z-index: -1;
  background: repeating-conic-gradient(
    rgba(255,255,255,.01) 0% 25%, transparent 0% 50%
  );
  background-size: 60px 60px;
  pointer-events: none;
  animation: subtleMove 60s linear infinite;
}

@keyframes subtleMove {
  from { transform: translate(0, 0); }
  to   { transform: translate(30px, 30px); }
}

/* ---------- Layout ---------- */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header / Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,15,20,.75);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  transition: all var(--transition);
}

.navbar.scrolled {
  box-shadow: 0 4px 24px rgba(0,0,0,.3);
  border-bottom-color: var(--border-hover);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: opacity var(--transition);
}

.logo:hover { opacity: .85; }

.logo-icon {
  width: 30px;
  height: 30px;
  background: var(--gradient-accent);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: .85rem;
  font-weight: 800;
  box-shadow: 0 2px 12px rgba(99,102,241,.3);
}

/* ---------- Copy Link Button (Post Page) ---------- */
.btn-copy-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-copy-link:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

.btn-copy-link:active {
  transform: scale(.96);
}

.btn-copy-link.copied {
  color: var(--success);
  border-color: rgba(34,197,94,.3);
  background: var(--success-soft);
}

.btn-copy-link svg {
  transition: transform var(--spring);
}

.btn-copy-link.copied svg {
  transform: scale(1.15);
}

/* ---------- Editor Page ---------- */
.editor-wrapper {
  padding: 48px 0 120px;
  animation: fadeUp .6s cubic-bezier(.22,1,.36,1) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Title input */
.editor-title {
  width: 100%;
  font-family: var(--font-serif);
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--text);
  border: none;
  outline: none;
  background: transparent;
  padding: 0 0 8px;
  line-height: 1.2;
  letter-spacing: -.02em;
  resize: none;
  overflow: hidden;
  caret-color: var(--accent);
}

.editor-title::placeholder {
  color: var(--text-light);
}

/* Divider */
.editor-divider {
  width: 48px;
  height: 3px;
  background: var(--surface-2);
  border-radius: 2px;
  margin: 20px 0 28px;
  transition: all .4s ease;
}

.editor-title:focus ~ .editor-divider {
  background: var(--accent);
  width: 64px;
  box-shadow: 0 0 16px rgba(99,102,241,.4);
}

/* Content area */
.editor-content {
  width: 100%;
  min-height: 320px;
  font-family: var(--font-sans);
  font-size: 1.08rem;
  line-height: 1.85;
  color: var(--text);
  border: none;
  outline: none;
  background: transparent;
  resize: vertical;
  padding: 0;
  caret-color: var(--accent);
}

.editor-content::placeholder {
  color: var(--text-light);
}

/* Hint text */
.editor-hint {
  margin-top: 24px;
  font-family: var(--font-sans);
  font-size: .78rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-hint svg {
  opacity: .4;
}

/* ---------- Image Preview Container ---------- */
.image-preview-area {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.image-preview-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  animation: fadeUp .4s cubic-bezier(.22,1,.36,1) both;
  position: relative;
  background: var(--surface);
}

.image-preview-card img {
  width: 100%;
  display: block;
  object-fit: cover;
  max-height: 480px;
  background: var(--surface);
  transition: transform .5s ease;
}

.image-preview-card:hover img {
  transform: scale(1.01);
}

.image-preview-card .image-url-label {
  font-family: var(--font-sans);
  font-size: .7rem;
  color: var(--text-light);
  padding: 8px 14px;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Publish Bar ---------- */
.publish-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(15,15,20,.85);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-top: 1px solid var(--border);
  transform: translateY(100%);
  transition: transform .4s cubic-bezier(.22,1,.36,1);
}

.publish-bar.visible {
  transform: translateY(0);
}

.publish-bar .container {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 64px;
  gap: 12px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .88rem;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
  user-select: none;
  text-decoration: none;
}

.btn:active {
  transform: scale(.96);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px rgba(99,102,241,.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0) scale(.97);
}

.btn-primary:disabled {
  opacity: .4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  box-shadow: 0 4px 14px rgba(34,197,94,.3);
}

/* Spinner inside button */
.btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Post Viewer Page ---------- */
.post-wrapper {
  padding: 56px 0 80px;
  animation: fadeUp .6s cubic-bezier(.22,1,.36,1) both;
}

.post-meta {
  font-family: var(--font-sans);
  font-size: .8rem;
  color: var(--text-light);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.post-title {
  font-family: var(--font-serif);
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 8px;
}

.post-divider {
  width: 48px;
  height: 3px;
  background: var(--gradient-accent);
  border-radius: 2px;
  margin: 20px 0 32px;
  box-shadow: 0 0 12px rgba(99,102,241,.3);
}

.post-body {
  font-family: var(--font-sans);
  font-size: 1.08rem;
  line-height: 1.85;
  color: rgba(240,240,245,.85);
}

.post-body p {
  margin-bottom: 1.2em;
}

.post-body a {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(129,140,248,.3);
  transition: all var(--transition);
}

.post-body a:hover {
  color: #a5b4fc;
  text-decoration-color: rgba(165,180,252,.6);
}

.post-body img {
  width: 100%;
  border-radius: var(--radius);
  margin: 16px 0;
  display: block;
}

.post-body .image-block {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin: 24px 0;
  background: var(--surface);
  transition: border-color var(--transition);
}

.post-body .image-block:hover {
  border-color: var(--border-hover);
}

.post-body .image-block img {
  width: 100%;
  display: block;
  border-radius: 0;
  margin: 0;
  transition: transform .5s ease;
}

.post-body .image-block:hover img {
  transform: scale(1.01);
}

/* ---------- Success Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 32px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.4);
  transform: scale(.9) translateY(20px);
  transition: transform .4s cubic-bezier(.22,1,.36,1);
}

.modal-overlay.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  font-size: 1.5rem;
}

.modal-card h2 {
  font-family: var(--font-sans);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.modal-card p {
  font-family: var(--font-sans);
  font-size: .9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal-link-box {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--surface);
}

.modal-link-box input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-sans);
  font-size: .82rem;
  padding: 12px 14px;
  border: none;
  outline: none;
  color: var(--text);
  background: transparent;
  text-overflow: ellipsis;
  overflow: hidden;
}

.modal-link-box .copy-btn {
  flex-shrink: 0;
  padding: 12px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .82rem;
  transition: all var(--transition);
  white-space: nowrap;
}

.modal-link-box .copy-btn:hover {
  background: var(--accent-hover);
}

.modal-link-box .copy-btn:active {
  transform: scale(.95);
}

.modal-link-box .copy-btn.copied {
  background: var(--success);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  font-family: var(--font-sans);
  font-size: .85rem;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  color: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  animation: toastIn .4s cubic-bezier(.22,1,.36,1) both;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,.06);
}

.toast.error   { background: var(--danger); }
.toast.success { background: var(--success); }
.toast.info    { background: var(--accent); }

.toast.out {
  animation: toastOut .3s ease both;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(32px) scale(.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(32px) scale(.9); }
}

/* ---------- 404 Page ---------- */
.error-wrapper {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
  animation: fadeUp .6s cubic-bezier(.22,1,.36,1) both;
}

.error-code {
  font-family: var(--font-sans);
  font-size: 8rem;
  font-weight: 800;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 30px rgba(99,102,241,.3));
}

.error-wrapper h2 {
  font-family: var(--font-sans);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.error-wrapper p {
  font-family: var(--font-sans);
  font-size: .95rem;
  color: var(--text-muted);
  margin-bottom: 32px;
  max-width: 380px;
}

/* ---------- Loading Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease infinite;
  border-radius: var(--radius-sm);
}

.skeleton-title {
  height: 40px;
  width: 70%;
  margin-bottom: 20px;
}

.skeleton-line {
  height: 18px;
  margin-bottom: 12px;
}

.skeleton-line:nth-child(2) { width: 90%; }
.skeleton-line:nth-child(3) { width: 85%; }
.skeleton-line:nth-child(4) { width: 60%; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 32px 0;
  font-family: var(--font-sans);
  font-size: .76rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.footer a:hover {
  color: var(--accent-hover);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .container { padding: 0 16px; }

  .editor-title,
  .post-title {
    font-size: 1.85rem;
  }

  .editor-content,
  .post-body {
    font-size: 1rem;
  }

  .error-code {
    font-size: 5rem;
  }

  .modal-card {
    padding: 32px 20px;
  }

  .publish-bar .container {
    height: 56px;
  }

  .btn-copy-link .copy-label {
    display: none;
  }

  .btn-copy-link {
    padding: 8px 12px;
  }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* ---------- Focus Visible ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Link styling in post ---------- */
.post-body .auto-link {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(129,140,248,.3);
  word-break: break-all;
  transition: all var(--transition);
}

.post-body .auto-link:hover {
  color: #a5b4fc;
  text-decoration-color: rgba(165,180,252,.6);
}

/* ---------- Textarea styling fix ---------- */
textarea {
  font-family: inherit;
  color: inherit;
}
