/* Law Firm News Aggregator UI
   Blue primary + orange accent, business, readable */

:root {
  /* Brand */
  --blue-900: #0b255a;
  /* Slightly lighter navy for header + accents */
  --blue-800: #123a85;
  --blue-700: #1742b6;
  --blue-600: #2457e6;
  /* Slightly deeper light-blue tint for backgrounds */
  --blue-100: #e6efff;

  /* Slightly lighter orange accents */
  --orange-600: #ea580c;
  --orange-500: #fb923c;
  --orange-100: #ffedd5;

  /* Neutrals */
  /* Slightly deeper overall page background */
  --bg: #f5f7ff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: rgba(15, 23, 42, 0.10);
  --text: #0f172a;
  --text-2: rgba(15, 23, 42, 0.78);
  --text-3: rgba(15, 23, 42, 0.58);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --focus: rgba(36, 87, 230, 0.25);
  --focus-border: rgba(36, 87, 230, 0.55);

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  /* Softer, more natural background (avoid "stitched" segments while scrolling) */
  background:
    radial-gradient(1200px 520px at 18% -10%, rgba(36, 87, 230, 0.22), rgba(36, 87, 230, 0) 62%),
    radial-gradient(900px 520px at 90% 0%, rgba(11, 37, 90, 0.10), rgba(11, 37, 90, 0) 58%),
    radial-gradient(900px 520px at 88% 12%, rgba(249, 115, 22, 0.10), rgba(249, 115, 22, 0) 56%),
    linear-gradient(180deg, var(--blue-100) 0%, var(--bg) 42%, var(--bg) 100%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--text);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    Arial,
    sans-serif;
  line-height: 1.6;
  letter-spacing: 0.2px;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

code {
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    "Courier New",
    monospace;
  font-size: 0.95em;
}

/* App shell: like "min-h-screen" layout */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout */
.container {
  /* Similar to Tailwind max-w-5xl (1024px) for better readability */
  max-width: 1024px;
  margin: 0 auto;
  /* Use left/right padding only so we don't override vertical padding on
     elements that also use `.container` (e.g. `.header-wrap`). */
  padding-left: 16px; /* px-4 */
  padding-right: 16px;
}

.app-header {
  position: relative;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.app-header-primary {
  background: var(--blue-800);
  color: rgba(255, 255, 255, 0.92);
}

.header-accent {
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--orange-500), #fdba74);
}

.header-wrap {
  /* Only vertical padding; keep container's horizontal padding */
  padding-top: 0;
  padding-bottom: 24px;
}

.header-title {
  margin: -11px 0 0;
  text-align: center;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 850;
  letter-spacing: -0.2px;
  color: rgba(255, 255, 255, 0.96);
  font-family:
    ui-serif,
    Georgia,
    Cambria,
    "Times New Roman",
    Times,
    serif;
}

.header-subtitle {
  margin: 10px 0 0;
  text-align: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.70);
}

/* 顶部左侧 China / Global 切换 */
.header-top-row {
  display: flex;
  align-items: center;
  padding: 12px 20px 0;
  padding-left: 32px;
}

.scope-toggle {
  display: inline-flex;
  gap: 3px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  padding: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.scope-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.scope-toggle-btn:hover {
  color: rgba(255, 255, 255, 1);
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
  transform: translateY(-0.5px);
}

.scope-toggle-btn.is-active {
  background: rgba(255, 255, 255, 0.98);
  color: var(--blue-800);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.scope-flag {
  flex-shrink: 0;
  border-radius: 2px;
  display: block;
}

.scope-flag {
  width: 18px;
  height: 12px;
}

.scope-icon {
  font-size: 15px;
  line-height: 1;
  opacity: 0.95;
}

.header-controls {
  margin-top: 20px;
}

.header-controls-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.header-search {
  position: relative;
  flex: 1;
}

.header-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: rgba(15, 23, 42, 0.45);
  pointer-events: none;
}

.header-input {
  height: 44px;
  /* Ensure placeholder never overlaps the icon */
  padding-left: 46px;
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(255, 255, 255, 0.22);
}

.header-select {
  height: 44px;
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(255, 255, 255, 0.22);
}

.header-kpi {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.header-kpi-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
}

.header-kpi-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--orange-500);
  color: #111827;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.20);
}

.app-main {
  flex: 1;
  /* Slightly tighter gap under the header and less bottom empty space */
  padding: 18px 0 36px;
}

.app-footer {
  padding: 18px 0 34px;
  color: var(--text-3);
  font-size: 12px;
}

/* Helpers */
.muted {
  color: var(--text-3);
}

.kpi {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.kpi strong {
  color: var(--text);
  font-weight: 700;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
}

.skip-link:focus {
  left: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
  outline: none;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.btn:active {
  transform: translateY(0.5px);
}

.btn-primary {
  background: linear-gradient(180deg, var(--blue-600), var(--blue-700));
  color: #fff;
  box-shadow: 0 10px 20px rgba(36, 87, 230, 0.18);
}

.btn-primary:hover {
  text-decoration: none;
  box-shadow: 0 14px 28px rgba(36, 87, 230, 0.22);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.65);
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover {
  text-decoration: none;
  background: var(--surface);
  border-color: rgba(15, 23, 42, 0.18);
}

.btn-accent {
  background: linear-gradient(180deg, #fdba74, var(--orange-500));
  color: #1f2937;
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.18);
}

.btn-accent:hover {
  text-decoration: none;
  box-shadow: 0 14px 28px rgba(249, 115, 22, 0.22);
}

.btn-accent-soft {
  background: linear-gradient(180deg, rgba(255, 237, 213, 0.95), rgba(255, 237, 213, 0.70));
  border-color: rgba(249, 115, 22, 0.40);
  color: #7c2d12;
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.10);
}

.btn-accent-soft:hover {
  text-decoration: none;
  background: linear-gradient(180deg, rgba(255, 237, 213, 1), rgba(255, 237, 213, 0.78));
  border-color: rgba(249, 115, 22, 0.55);
  box-shadow: 0 14px 28px rgba(249, 115, 22, 0.14);
}

.btn-full {
  width: 100%;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: end;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 650;
  color: var(--text-2);
  margin-bottom: 6px;
}

.input,
.select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.04);
}

/* Ensure header search text never overlaps the icon.
   This must come AFTER the base `.input { padding: ... }` rule. */
.input.header-input {
  padding-left: 52px;
}

.select {
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(15, 23, 42, 0.55) 50%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.55) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 55%,
    calc(100% - 13px) 55%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.input::placeholder {
  color: rgba(15, 23, 42, 0.42);
}

.input:focus-visible,
.select:focus-visible,
.btn:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.input:focus,
.select:focus {
  border-color: var(--focus-border);
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Article list */
.sortbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  color: rgba(15, 23, 42, 0.55);
  font-size: 13px;
  flex-wrap: wrap;
}

.sortbar-left {
  color: rgba(15, 23, 42, 0.60);
}

.sortbar-left strong {
  color: rgba(15, 23, 42, 0.82);
  font-weight: 850;
}

.sortbar-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.sort-link {
  color: rgba(15, 23, 42, 0.62);
  text-decoration: none;
  padding: 6px 6px;
  border-radius: 10px;
  transition: color 160ms ease, background-color 160ms ease;
}

.sort-link:hover {
  color: rgba(30, 58, 138, 0.95);
  background: rgba(30, 58, 138, 0.06);
  text-decoration: none;
}

.sort-link.is-active {
  color: #1e3a8a;
  font-weight: 800;
}

.sort-sep {
  opacity: 0.55;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.article-card {
  padding: 18px 20px;
}

.article-body {
  min-width: 0;
}

.article-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.meta {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
}

.meta strong {
  color: var(--blue-800);
  font-weight: 750;
}

.meta .dot {
  opacity: 0.5;
}

.article-title {
  display: inline-block;
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 760;
  color: var(--text);
  cursor: default;
}

.badge-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--orange-500);
  color: #111827;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.18);
}

.badge-new-inline {
  transform: translateY(-1px);
}

.summary {
  margin-top: 10px;
  font-size: 14px;
  color: var(--text-2);
}

/* 搜索词高亮：浅橘色，四角微圆，更易辨认 */
.search-highlight {
  background: linear-gradient(to bottom, rgba(255, 230, 200, 0.98) 0%, rgba(255, 210, 170, 0.95) 100%);
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
  color: var(--blue-900);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* Article footer (meta + actions) */
.article-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-meta {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  color: rgba(15, 23, 42, 0.62);
  font-size: 12px;
  min-width: 0;
}

.footer-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.footer-meta-firm > span {
  font-weight: 800;
  color: #1e3a8a;
}

.footer-meta-item > span {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.footer-meta-icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: rgba(15, 23, 42, 0.45);
}

.footer-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

/* Like button */
.like-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: transparent;
  color: rgba(15, 23, 42, 0.55);
  cursor: pointer;
  user-select: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.like-btn:hover {
  background: rgba(30, 58, 138, 0.06);
  border-color: rgba(30, 58, 138, 0.18);
  color: rgba(15, 23, 42, 0.70);
}

.like-btn:active {
  transform: scale(0.98);
}

.like-btn:disabled {
  cursor: not-allowed;
}

.like-btn.is-liked {
  border-color: rgba(30, 58, 138, 0.45);
  background: rgba(30, 58, 138, 0.06);
  color: #1e3a8a;
}

.like-btn.is-pulsing {
  animation: likePulse 220ms ease-out;
}

@keyframes likePulse {
  0% { transform: scale(1); }
  55% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.like-btn-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.like-btn-count {
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
}

/* Pager */
.pager {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.pager-left {
  font-size: 13px;
  color: var(--text-2);
}

.pager-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.pager-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pager-jump {
  display: none;
  gap: 10px;
  align-items: center;
  margin-left: 6px;
}

.pager-jump label {
  font-size: 13px;
  color: var(--text-2);
}

.pager-jump .input {
  width: 96px;
}

/* Minimal utilities used by templates */
.line-clamp-3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

@media (min-width: 900px) {
  .app-main {
    padding-top: 22px;
  }

  .form-grid {
    grid-template-columns: 4fr 6fr 2fr;
    gap: 14px;
  }

  .form-actions {
    grid-template-columns: 1fr 1fr;
  }

  .pager-jump {
    display: inline-flex;
  }
}

@media (min-width: 640px) {
  .container {
    padding-left: 24px; /* sm:px-6 */
    padding-right: 24px;
  }

  .header-title {
    font-size: 36px;
  }

  .header-controls-row {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }

  .header-select {
    width: 220px;
  }
}

@media (min-width: 1024px) {
  .container {
    padding-left: 32px; /* lg:px-8 */
    padding-right: 32px;
  }
}

/* "查看原文" ghost button */
.source-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid rgba(30, 58, 138, 0.75);
  color: rgba(255, 255, 255, 0.96);
  background: linear-gradient(180deg, #2549c7, #1e3a8a);
  text-decoration: none;
  user-select: none;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(30, 58, 138, 0.18);
  transition: transform 200ms ease, box-shadow 220ms ease, filter 220ms ease;
}

.source-btn::after {
  /* soft vertical sheen moving left -> right */
  content: "";
  position: absolute;
  top: 0;
  left: -45%;
  width: 45%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.28) 45%,
    rgba(255, 255, 255, 0.36) 50%,
    rgba(255, 255, 255, 0.28) 55%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateX(0);
  opacity: 0;
  filter: blur(0.4px);
  pointer-events: none;
  transition: transform 650ms ease, opacity 240ms ease;
}

.source-btn:hover {
  filter: brightness(1.03) saturate(1.02);
  box-shadow: 0 14px 30px rgba(30, 58, 138, 0.26);
}

.source-btn:hover::after {
  opacity: 1;
  transform: translateX(260%);
}

.source-btn:active {
  transform: scale(0.98);
}

.source-btn > span {
  white-space: nowrap;
}

.source-btn-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.source-btn-ext {
  width: 15px;
  height: 15px;
  opacity: 0.80;
  flex: 0 0 auto;
  transition: transform 200ms ease, opacity 200ms ease;
}

.source-btn:hover .source-btn-ext {
  transform: translate(2px, -2px);
  opacity: 1;
}
