/* =========================================================
   TECHORIA — design tokens
   Display: Space Grotesk (bold, geometric, headline personality)
   Body: Inter (clean, high-legibility)
   Utility/mono: JetBrains Mono (bylines, timestamps, eyebrows — "data feed" feel)
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500&display=swap');

:root {
  --ink: #14151A;
  --paper: #FFFFFF;
  --surface: #F4F5F7;
  --line: #E4E5E9;
  --muted: #6B6E76;
  --navy: #0B1220;
  --navy-raised: #161E2E;
  --accent: #FF4B1F;
  --accent-ink: #FFFFFF;
  --danger: #C0392B;
  --success: #059669;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============ Public site header ============ */
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); box-shadow: 0 2px 12px rgba(0,0,0,0.06); position: sticky; top: 0; z-index: 50; }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; gap: 24px;
}
.mobile-header-icons { display: flex; align-items: center; gap: 2px; }
.brand {
  font-family: var(--font-display); font-weight: 700; font-size: 22px;
  color: var(--ink); letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px;
}
.brand span { color: var(--accent); }
.brand-mark-icon { flex-shrink: 0; }
.site-nav { display: flex; gap: 4px; flex: 1; justify-content: center; flex-wrap: wrap; }
.site-nav a {
  color: var(--ink); font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: 6px; transition: color .15s, background .15s;
}
.site-nav a:hover, .site-nav a.active { color: var(--accent); background: var(--surface); }
.nav-dropdown { position: relative; }
.nav-dropdown-toggle {
  background: none; border: none; font-family: inherit; cursor: pointer;
  color: var(--ink); font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: 6px; transition: color .15s, background .15s;
}
.nav-dropdown-toggle:hover, .nav-dropdown.open .nav-dropdown-toggle { color: var(--accent); background: var(--surface); }
.nav-dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0; margin-top: 4px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 6px;
  min-width: 180px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 60;
  flex-direction: column;
}
.nav-dropdown.open .nav-dropdown-menu { display: flex; }
.nav-dropdown-menu a { padding: 9px 14px; color: var(--ink); border-radius: 6px; font-size: 14px; }
.nav-dropdown-menu a:hover { background: var(--surface); color: var(--accent); }
.nav-panel-head { display: none; }
.header-search { display: flex; align-items: center; }
.header-search input {
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink); padding: 8px 14px; border-radius: 20px; font-size: 13px; width: 180px;
}
.header-search input::placeholder { color: var(--muted); }

/* ============ Hero (lead story) ============ */
.hero-lead {
  display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 40px;
  padding: 48px 0 40px; border-bottom: 1px solid var(--line);
  align-items: center;
}
.hero-lead-image { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; background: var(--surface); }
.hero-lead h1 {
  font-family: var(--font-display); font-weight: 700; font-size: 42px; line-height: 1.08;
  margin: 14px 0 16px; letter-spacing: -0.01em;
}
.hero-lead .post-excerpt { font-size: 17px; color: var(--muted); margin-bottom: 18px; }
.category-tag {
  display: inline-block; font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.06em; padding: 4px 10px; border-radius: 4px;
  color: white; margin-bottom: 4px;
}
.byline { font-family: var(--font-mono); font-size: 12px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.byline .dot::before { content: "•"; margin-right: 10px; opacity: 0.5; }

/* ============ Post grid ============ */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 44px 0 20px; }
.section-head h2 { font-family: var(--font-display); font-size: 22px; margin: 0; }
.section-head a { font-size: 13px; font-weight: 600; color: var(--accent); }

.breadcrumbs {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0 4px;
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs .sep { opacity: 0.5; }
.breadcrumbs .current { color: var(--ink); }

.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; padding-bottom: 40px; }
.post-card { display: flex; flex-direction: column; }
.post-card-image { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 8px; background: var(--surface); margin-bottom: 12px; }
.post-card h3 { font-family: var(--font-display); font-size: 19px; font-weight: 700; margin: 6px 0 8px; line-height: 1.25; }
.post-card .post-excerpt { font-size: 14px; color: var(--muted); margin: 0 0 10px; }
.empty-state { color: var(--muted); padding: 60px 0; text-align: center; }

/* ============ Layout with trending sidebar ============ */
.content-layout { display: grid; grid-template-columns: 1fr 300px; gap: 48px; align-items: start; }
.trending-panel { background: var(--surface); border-radius: 10px; padding: 24px; position: sticky; top: 90px; }
.trending-panel h2 { font-family: var(--font-display); font-size: 16px; margin: 0 0 16px; }
.trending-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.trending-item:last-child { border-bottom: none; }
.trending-rank { font-family: var(--font-mono); font-size: 20px; font-weight: 500; color: var(--accent); width: 24px; flex-shrink: 0; }
.trending-item h4 { font-size: 14px; font-weight: 600; margin: 0 0 4px; line-height: 1.3; }
.trending-item .byline { font-size: 11px; }

/* ============ Single post ============ */
.post-single { padding: 40px 0 60px; max-width: 760px; margin: 0 auto; }
.post-single h1 {
  font-family: var(--font-display); font-weight: 700; font-size: 38px; line-height: 1.12;
  margin: 14px 0 18px; letter-spacing: -0.01em;
}
.post-single-image { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; margin: 24px 0; background: var(--surface); }
.post-body { font-size: 18px; }
.post-body p { margin: 0 0 20px; }
.post-body a { color: #2563EB; text-decoration: underline; text-underline-offset: 2px; }
.post-body a:hover { color: #1D4ED8; }
.post-body h2 { font-family: var(--font-display); font-size: 26px; margin: 36px 0 14px; }
.post-body h3 { font-family: var(--font-display); font-size: 21px; margin: 28px 0 12px; }
.post-body img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.post-body blockquote {
  border-left: 3px solid var(--accent); margin: 24px 0; padding: 4px 0 4px 20px;
  font-style: italic; color: var(--muted);
}
.post-body pre { background: var(--navy); color: #e5e7eb; padding: 16px; border-radius: 8px; overflow-x: auto; font-family: var(--font-mono); font-size: 14px; }
.post-tags { margin-top: 36px; display: flex; gap: 8px; flex-wrap: wrap; }
.tag-pill { background: var(--surface); color: var(--muted); font-size: 13px; padding: 5px 12px; border-radius: 20px; }
.back-link { margin-top: 40px; font-weight: 600; }
.back-link a { color: var(--accent); }

/* ============ Related posts ============ */
.related-posts { border-top: 1px solid var(--line); margin-top: 48px; padding-top: 32px; }

/* ============ Static pages ============ */
.static-page { padding: 48px 0 60px; max-width: 720px; margin: 0 auto; }
.static-page h1 { font-family: var(--font-display); font-size: 34px; }
.static-page h2 { font-family: var(--font-display); font-size: 21px; margin-top: 32px; }

/* ============ Forms (public) ============ */
.contact-form { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; max-width: 480px; }
.contact-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
input, textarea, select {
  font-family: var(--font-body); font-size: 15px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }
button {
  align-self: flex-start; background: var(--ink); color: white; border: none;
  padding: 12px 26px; border-radius: 8px; font-weight: 600; cursor: pointer; font-size: 15px;
  transition: background .15s;
}
button:hover { background: #2a2c34; }
.form-error { color: var(--danger); font-weight: 600; }
.form-success { color: var(--success); font-weight: 600; }

/* ============ Footer ============ */
.site-footer { background: var(--navy); color: rgba(255,255,255,0.6); margin-top: 40px; padding: 40px 0; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; font-size: 14px; }
.footer-nav a { margin-left: 18px; color: rgba(255,255,255,0.6); }
.footer-nav a:hover { color: white; }

/* =========================================================
   ADMIN — newsroom dashboard
   ========================================================= */
.admin-body { background: var(--surface); font-family: var(--font-body); }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); }
.login-box { background: var(--navy-raised); border-radius: 14px; padding: 40px; width: 360px; border: 1px solid rgba(255,255,255,0.08); }
.login-brand { font-family: var(--font-display); font-weight: 700; font-size: 24px; color: white; letter-spacing: -0.01em; }
.login-brand span { color: var(--accent); }
.login-sub { color: rgba(255,255,255,0.5); font-size: 14px; margin: 6px 0 24px; }
.login-box form { display: flex; flex-direction: column; gap: 16px; }
.login-box label { color: rgba(255,255,255,0.7); font-size: 13px; font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
.login-box input { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); color: white; }
.login-box button { background: var(--accent); width: 100%; align-self: stretch; text-align: center; }
.login-box button:hover { background: #e6420f; }

.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 232px; background: var(--navy); color: white; flex-shrink: 0; padding: 24px 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.admin-brand { font-family: var(--font-display); font-weight: 700; font-size: 19px; padding: 0 24px 8px; }
.admin-brand span { color: var(--accent); }
.admin-user-badge { padding: 0 24px 24px; }
.admin-user-name { font-size: 13px; font-weight: 600; }
.admin-user-role { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.admin-sidebar nav { display: flex; flex-direction: column; flex: 1; }
.admin-sidebar nav a { color: rgba(255,255,255,0.72); padding: 11px 24px; font-size: 14px; font-weight: 500; border-left: 3px solid transparent; }
.admin-sidebar nav a:hover { background: rgba(255,255,255,0.06); color: white; }
.admin-sidebar nav a.active { background: rgba(255,255,255,0.08); color: white; border-left-color: var(--accent); }
.admin-sidebar nav a.logout-link { margin-top: auto; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 16px; }
.admin-main { flex: 1; padding: 40px 44px; max-width: 1200px; }

.admin-page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.admin-page-head h1 { font-family: var(--font-display); font-size: 26px; margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 22px; display: flex; flex-direction: column; gap: 4px; }
.stat-number { font-family: var(--font-display); font-size: 32px; font-weight: 700; color: var(--ink); }
.stat-label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.admin-panel { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 22px; }
.admin-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.admin-panel-head h2 { font-family: var(--font-display); font-size: 17px; margin: 0; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { flex: 1; min-width: 160px; }

.form-row { display: flex; gap: 16px; }
.form-row label { flex: 1; }

.post-form { display: flex; flex-direction: column; gap: 18px; }
.post-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.post-form small { color: var(--muted); font-weight: 400; font-size: 12px; }

.rich-editor { background: white; min-height: 280px; border-radius: 0 0 8px 8px; }
.ql-toolbar { border-radius: 8px 8px 0 0; }
.ql-toolbar, .ql-container { border-color: var(--line) !important; }

.seo-fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.seo-fieldset legend { font-family: var(--font-mono); font-weight: 500; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; padding: 0 6px; }

.admin-table { width: 100%; border-collapse: collapse; background: var(--paper); border-radius: 10px; overflow: hidden; }
.admin-table th, .admin-table td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.admin-table th { background: var(--surface); font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 500; }

.tag { padding: 3px 9px; border-radius: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; font-family: var(--font-mono); letter-spacing: 0.04em; }
.tag-published { background: #DCFCE7; color: #16803C; }
.tag-draft { background: #FEF3C7; color: #B45309; }
.tag-admin { background: #EDE9FE; color: #6D28D9; }
.tag-editor { background: #DBEAFE; color: #1D4ED8; }

.btn, .btn-ghost { display: inline-block; padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: 14px; margin-left: 8px; }
.btn { background: var(--accent); color: white; }
.btn:hover { background: #e6420f; text-decoration: none; }
.btn-ghost { color: var(--ink); border: 1px solid var(--line); background: var(--paper); }
.btn-ghost:hover { text-decoration: none; background: var(--surface); }
.danger-link { color: var(--danger); }

@media (max-width: 900px) {
  .hero-lead { grid-template-columns: 1fr; }
  .content-layout { grid-template-columns: 1fr; }
  .trending-panel { position: static; }
  .post-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 800px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; height: auto; position: static; padding: 16px 0; }
  .admin-sidebar nav { flex-direction: row; overflow-x: auto; padding: 0 12px; }
  .admin-sidebar nav a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .admin-sidebar nav a.active { border-left: none; border-bottom-color: var(--accent); }
  .admin-sidebar nav a.logout-link { margin-top: 0; border-top: none; }
  .admin-main { padding: 24px 18px; }
  .form-row { flex-direction: column; }
}

@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; }
  .hero-lead h1 { font-size: 30px; }
  .post-single h1 { font-size: 28px; }
  .post-grid { grid-template-columns: 1fr; }

  #mobile-nav-toggle { display: block !important; color: var(--ink) !important; }
  #mobile-nav-close { display: block !important; color: var(--ink) !important; }
  #mobile-search-toggle { display: block !important; color: var(--ink) !important; }
  .nav-panel-head { display: flex !important; }

  .site-nav {
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    width: 250px;
    background: var(--paper);
    border-left: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 0 0 20px;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 99;
    overflow-y: auto;
    box-shadow: -8px 0 24px rgba(0,0,0,0.08);
  }
  .site-nav.nav-open { transform: translateX(0); }
  .nav-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
  }
  .nav-panel-head span { font-family: var(--font-display); font-weight: 700; font-size: 16px; }
  .site-nav a { width: 100%; padding: 14px 18px; color: var(--ink); border-bottom: 1px solid var(--surface); }
  .site-nav a:last-child { border-bottom: none; }
  #mobile-nav-backdrop.backdrop-open { display: block !important; }

  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    background: var(--surface);
    margin: 4px 0 4px 12px;
  }

  .site-search {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
    z-index: 97;
  }
  .site-search.search-open { display: flex !important; }
  .site-search input { flex: 1; }
}