/* ====================================================================
   The Daily Briefing — editorial city dashboard
   Palette: ivory paper / ink / rust clay
==================================================================== */

:root {
  --paper: #f6f1e6;
  --paper-2: #efe7d5;
  --ink: #1a1612;
  --ink-soft: #4a4036;
  --ink-mute: #7a6f5f;
  --rule: #cdbfa1;
  --rust: #c84927;
  --rust-dark: #8e2f17;
  --gold: #b9893a;
  --sky: #4a6b85;

  --serif: 'Fraunces', 'Iowan Old Style', 'Apple Garamond', Georgia, serif;
  --sans: 'Instrument Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01', 'ss02', 'cv11';
  min-height: 100vh;
  overflow-x: hidden;
}

/* Paper grain — subtle SVG noise overlay */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  opacity: 0.08; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.08 0 0 0 0 0.06 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ====== MASTHEAD ====== */
.masthead {
  padding: 28px max(28px, 5vw) 16px;
  border-bottom: 2px solid var(--ink);
  position: relative;
}
.masthead::after {
  content: ''; position: absolute; left: max(28px, 5vw); right: max(28px, 5vw);
  bottom: -6px; height: 2px; background: var(--ink);
}

.masthead-line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.title {
  margin: 26px 0 18px;
  font-family: var(--serif);
  font-weight: 320;
  font-variation-settings: 'opsz' 144, 'SOFT' 30;
  font-size: clamp(48px, 9.5vw, 124px);
  line-height: 0.95;
  letter-spacing: -0.025em;
  text-align: center;
  color: var(--ink);
}
.title em {
  font-style: italic;
  font-variation-settings: 'opsz' 144, 'SOFT' 80;
  color: var(--rust);
  font-weight: 360;
}
#city-name {
  display: inline-block;
  text-transform: capitalize;
}
.title-divider {
  display: inline-block;
  width: 0.6ch;
  text-align: center;
}
.title-divider::before { content: '·'; color: var(--ink-soft); margin: 0 0.15em; }

.city-bar {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}
.city-bar label {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-mute);
}
.city-bar input {
  font-family: var(--serif);
  font-size: 17px; font-style: italic;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink);
  color: var(--ink);
  padding: 4px 8px;
  width: 240px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.city-bar input:focus { border-color: var(--rust); }
.city-bar input::placeholder { color: var(--ink-mute); font-style: italic; opacity: 0.6; }
.city-bar button {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.15em;
  background: var(--ink); color: var(--paper);
  border: none; padding: 8px 14px; cursor: pointer;
  transition: background 0.15s;
}
.city-bar button:hover { background: var(--rust); }

/* ====== PAGE ====== */
.page {
  padding: 0 max(28px, 5vw) 60px;
  max-width: 1500px;
  margin: 0 auto;
}

/* ====== WEATHER ====== */
.weather {
  margin: 40px 0 32px;
  padding: 36px 32px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 2px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 28px;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.weather::before {
  content: 'TODAY'; position: absolute; top: 12px; left: 18px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.25em; color: var(--ink-mute);
}
.weather-skel {
  grid-column: 1 / -1;
  text-align: center; padding: 20px;
  font-family: var(--serif); font-style: italic; font-size: 22px; color: var(--ink-soft);
}
.w-temp {
  font-family: var(--serif);
  font-size: clamp(80px, 12vw, 140px);
  line-height: 0.9;
  font-weight: 200;
  font-variation-settings: 'opsz' 144;
  letter-spacing: -0.04em;
  color: var(--ink);
  position: relative;
}
.w-temp sup {
  font-size: 0.3em;
  vertical-align: top;
  margin-left: 4px;
  color: var(--rust);
  font-weight: 400;
}
.w-mid h2 {
  font-family: var(--serif); font-style: italic; font-weight: 360;
  font-variation-settings: 'opsz' 144;
  font-size: clamp(28px, 4vw, 42px);
  margin: 0 0 8px; color: var(--ink);
  text-transform: capitalize;
}
.w-mid .w-feels {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--ink-mute);
}
.w-mid .w-place {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 6px;
}
.w-meta {
  display: flex; flex-direction: column; gap: 10px;
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-soft);
  border-left: 1px solid var(--rule);
  padding-left: 24px;
}
.w-meta .row { display: flex; justify-content: space-between; gap: 16px; min-width: 150px; }
.w-meta .lbl { color: var(--ink-mute); text-transform: uppercase; letter-spacing: 0.15em; font-size: 10px; }
.w-meta .val { color: var(--ink); }

.w-forecast {
  grid-column: 1 / -1;
  display: flex; gap: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  overflow-x: auto;
}
.w-fc-cell {
  flex: 1 0 70px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
}
.w-fc-cell .t { font-size: 18px; color: var(--ink); margin-top: 4px; font-family: var(--serif); font-weight: 400; }

/* ====== COLUMNS ====== */
.columns {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 48px;
}
@media (max-width: 900px) {
  .columns { grid-template-columns: 1fr; gap: 36px; }
}

/* ====== FEED (NEWS / EVENTS) ====== */
.feed { min-width: 0; }
.tabs {
  display: flex; align-items: center; gap: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink);
  margin-bottom: 24px;
}
.tab {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 26px;
  background: transparent;
  border: none;
  padding: 0 14px 0 0;
  cursor: pointer;
  color: var(--ink-mute);
  font-style: italic;
  transition: color 0.15s;
}
.tab.active { color: var(--ink); font-style: normal; font-weight: 500; }
.tab.active::after {
  content: ''; display: block; height: 3px; background: var(--rust); width: 60%; margin-top: 4px;
}
.refresh {
  margin-left: auto;
  background: transparent; border: 1px solid var(--rule);
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; color: var(--ink-soft);
  font-size: 14px; transition: all 0.2s;
}
.refresh:hover { transform: rotate(180deg); border-color: var(--rust); color: var(--rust); }

.feed-body { display: flex; flex-direction: column; gap: 28px; }
.article {
  padding-bottom: 26px;
  border-bottom: 1px solid var(--rule);
}
.article:last-child { border-bottom: none; }
.article .meta {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--ink-mute);
  margin-bottom: 8px;
  display: flex; gap: 12px; align-items: center;
}
.article .meta .src { color: var(--rust); font-weight: 500; }
.article .meta .dot { color: var(--rule); }
.article h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.15;
  margin: 0 0 8px;
  letter-spacing: -0.012em;
}
.article h3 a {
  color: var(--ink);
  text-decoration: none;
  background: linear-gradient(var(--rust), var(--rust)) bottom left / 0% 1px no-repeat;
  transition: background-size 0.25s;
}
.article h3 a:hover { background-size: 100% 1px; color: var(--rust-dark); }
.article p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14.5px;
  line-height: 1.55;
}
.article.first h3 {
  font-size: 34px;
  font-weight: 360;
  font-variation-settings: 'opsz' 144;
}

.skeleton-row {
  height: 60px;
  background: linear-gradient(90deg, var(--paper-2) 0%, var(--rule) 50%, var(--paper-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 2px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty {
  font-family: var(--serif); font-style: italic; font-size: 18px;
  color: var(--ink-mute); text-align: center; padding: 40px 0;
}

/* ====== CHAT ====== */
.chat {
  background: var(--ink);
  color: var(--paper);
  padding: 28px;
  border-radius: 2px;
  display: flex; flex-direction: column;
  min-height: 600px;
  max-height: 800px;
  position: sticky;
  top: 24px;
  align-self: start;
}
@media (max-width: 900px) {
  .chat { position: static; min-height: 540px; }
}

.chat-head { border-bottom: 1px solid #3a342c; padding-bottom: 16px; margin-bottom: 16px; }
.chat-title {
  font-family: var(--serif); font-style: italic; font-weight: 360;
  font-size: 28px;
  font-variation-settings: 'opsz' 144;
  color: var(--paper);
}
.chat-sub {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em;
  text-transform: uppercase; color: #9c9080; margin-top: 4px;
}

.chat-body {
  flex: 1; overflow-y: auto; padding-right: 4px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: #3a342c; border-radius: 3px; }

.msg {
  font-size: 14.5px; line-height: 1.55;
  padding: 12px 14px;
  border-radius: 2px;
  max-width: 92%;
  word-wrap: break-word;
}
.msg-ai {
  background: #25201a;
  color: var(--paper);
  align-self: flex-start;
  border-left: 2px solid var(--rust);
}
.msg-user {
  background: var(--paper);
  color: var(--ink);
  align-self: flex-end;
  font-style: italic;
  font-family: var(--serif);
  font-size: 16px;
}
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin: 0; }
.msg.welcome p { margin: 0 0 12px; }

.quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  background: transparent;
  border: 1px solid #4a4036;
  color: #d5c8b0;
  padding: 6px 10px;
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.05em;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--rust); color: var(--paper); background: rgba(200,73,39,0.08); }

.typing {
  font-family: var(--mono); font-size: 11px; color: #9c9080;
  letter-spacing: 0.15em; padding: 8px 14px;
  display: flex; align-items: center; gap: 6px;
}
.typing .dot {
  width: 4px; height: 4px; background: var(--rust); border-radius: 50%;
  animation: bob 1.2s infinite;
}
.typing .dot:nth-child(2) { animation-delay: 0.15s; }
.typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes bob {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.chat-form {
  display: flex; gap: 8px; align-items: center;
  border-top: 1px solid #3a342c;
  padding-top: 16px;
  margin-top: 16px;
}
.chat-form input {
  flex: 1;
  background: transparent;
  border: 1px solid #4a4036;
  color: var(--paper);
  font-family: var(--sans);
  font-size: 14.5px;
  padding: 10px 12px;
  outline: none;
  border-radius: 2px;
}
.chat-form input::placeholder { color: #7a6f5f; font-style: italic; }
.chat-form input:focus { border-color: var(--rust); }
.chat-form button {
  width: 40px; height: 40px;
  background: var(--rust);
  border: none;
  color: var(--paper);
  font-size: 18px;
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s;
}
.chat-form button:hover:not(:disabled) { background: var(--rust-dark); }
.chat-form button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ====== FOOT ====== */
.foot {
  margin-top: 56px;
  padding-top: 18px;
  border-top: 2px solid var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}

/* ====== ENTRANCE ====== */
.fade-in { animation: fadeIn 0.6s ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile masthead tweaks */
@media (max-width: 640px) {
  .masthead { padding: 20px 18px 12px; }
  .page { padding: 0 18px 40px; }
  .masthead-line { flex-direction: column; gap: 4px; align-items: flex-start; padding-bottom: 12px; }
  .weather { grid-template-columns: 1fr; padding: 24px 18px; text-align: center; gap: 14px; }
  .w-meta { border-left: none; border-top: 1px solid var(--rule); padding: 14px 0 0; }
  .w-meta .row { justify-content: space-around; min-width: 0; }
  .city-bar input { width: 100%; max-width: 280px; }
  .article.first h3 { font-size: 26px; }
  .chat { padding: 20px; min-height: 480px; }
}
