/* ─── writing.css — /writing/ page styles ───────────────────────────────── */

/* ── PAGE HERO ───────────────────────────────────────────────────────────── */

.page-hero {
  position: relative;
  padding: 11rem 5vw 4rem;
  background: var(--ink);
  overflow: hidden;
}

.page-hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#page-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}

.page-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(10,10,10,0.5) 0%, rgba(10,10,10,0.94) 100%);
  z-index: 1;
}

.page-hero-content {
  position: relative;
  z-index: 2;
  max-width: 860px;
}

.page-hero-content .label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--white);
  margin-bottom: 1.25rem;
}

.page-hero-content h1 {
  font-size: clamp(3rem, 8vw, 7rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.92;
  margin-bottom: 0;
  opacity: 0;
  transform: translateY(50px);
  animation: pageUp 0.9s 0.25s var(--ease) forwards;
}

@keyframes pageUp {
  to { opacity: 1; transform: translateY(0); }
}

/* ── SECTION TABS ─────────────────────────────────────────────────────────── */

.section-tabs {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.section-tabs-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  gap: 0;
}

.section-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 1rem 1.25rem;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.section-tab:hover {
  color: var(--white);
}

.section-tab.active {
  color: var(--white);
  border-bottom-color: var(--accent);
}

/* ── WRITING MAIN ─────────────────────────────────────────────────────────── */

.writing-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.5rem 2rem 6rem;
}

/* ── INTRO TEXT ───────────────────────────────────────────────────────────── */

#blog_intro {
  margin-bottom: 1.5rem;
}

#blog_intro p {
  font-size: 0.97rem;
  line-height: 1.8;
  color: var(--white);
  max-width: 680px;
}

#blog_intro p b {
  color: var(--white);
  font-weight: 600;
}

#blog_intro h2, #blog_intro h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  margin: 1.5rem 0 0.5rem;
}

#blog_intro h3 { font-size: 0.95rem; }

#blog_intro ul {
  padding-left: 1.25rem;
  color: var(--white);
  font-size: 0.97rem;
  line-height: 2;
}

#blog_intro a {
  color: rgba(100, 160, 255, 0.85);
  text-decoration: none;
}
#blog_intro a:hover { text-decoration: underline; }

#blog_intro hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 1.5rem 0;
}

/* ── POST CARD — wraps nav bars + article as one unit ─────────────────────── */

.post-card {
  border-radius: 6px;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.38);
  overflow: hidden;
  margin: 0.5rem 0 1.5rem;
  position: relative;
}

/* ── POST NAVIGATION ──────────────────────────────────────────────────────── */

.post-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 3rem;
  background: #ece9e2;
}

#post-nav-top  .post-nav { border-bottom: 1px solid rgba(0, 0, 0, 0.09); }
#post-nav-bottom .post-nav { border-top:  1px solid rgba(0, 0, 0, 0.09); }

.post-nav-btn {
  background: none;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  padding: 0.4rem 1rem;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 500;
  color: #1a1a1a;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.post-nav-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.35);
}

.post-nav-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.post-nav-center {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.74rem;
  color: rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  flex-shrink: 0;
}

.post-nav-sep { opacity: 0.35; }

.post-nav-text-btn {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.74rem;
  color: rgba(0, 0, 0, 0.45);
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}

.post-nav-text-btn:hover:not(:disabled) { color: #0a0a0a; }
.post-nav-text-btn:disabled { opacity: 0.25; cursor: not-allowed; }

.post-nav-browse        { color: #8b1a1a; opacity: 0.85; }
.post-nav-browse:hover  { opacity: 1; }

.post-nav-delete {
  border-color: rgba(160, 30, 30, 0.3);
  color: #a01e1e;
  opacity: 0.6;
}
.post-nav-delete:hover:not(:disabled) {
  background: rgba(160, 30, 30, 0.07);
  border-color: rgba(160, 30, 30, 0.55);
  opacity: 1;
}

/* ── BROWSE DROPDOWN ──────────────────────────────────────────────────────── */

#browse-dropdown {
  position: absolute;
  z-index: 300;
  background: #f5f3ee;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.28);
  max-height: 52vh;
  overflow-y: auto;
  font-size: 0.83rem;
  line-height: 1;
  color: #1a1a1a;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.18) transparent;
}

.browse-header {
  padding: 0.75rem 1.25rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid rgba(0, 0, 0, 0.09);
  position: sticky;
  top: 0;
  background: #f5f3ee;
}

.browse-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.55rem 1.25rem;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  text-decoration: none;
  color: inherit;
}

.browse-item:hover { background: rgba(0, 0, 0, 0.05); }
.browse-item.current { background: rgba(139, 26, 26, 0.07); }

.browse-date {
  font-size: 0.72rem;
  color: rgba(0, 0, 0, 0.38);
  white-space: nowrap;
  flex-shrink: 0;
}

.browse-title { color: #1a1a1a; line-height: 1.35; }

/* ── POST CONTENT — document card ─────────────────────────────────────────── */

#preview_area {
  background: #f5f3ee;
  padding: 2.5rem 3rem 2rem;
  color: #1a1a1a;
}

#preview_area hr {
  border: none;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  margin: 1.5rem 0;
}

#blog_body {
  font-size: 0.97rem;
  line-height: 1.8;
}

.blog_title {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 1.5rem;
  color: #0a0a0a;
}

.post-dateline {
  display: flex;
  align-items: baseline;
  gap: 0;
  margin-bottom: 0.4rem;
  line-height: 1;
}

.post-year {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 800;
  color: #8b1a1a;
  letter-spacing: -0.02em;
}

.post-month-day {
  font-size: 1.3rem;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.42);
}

#blog_body p    { margin-bottom: 1rem; max-width: 700px; }
#blog_body ul,
#blog_body ol   { padding-left: 1.5rem; margin-bottom: 1rem; max-width: 700px; }
#blog_body li   { margin-bottom: 0.35rem; }
#blog_body h1   { font-size: 1.5rem; font-weight: 700; margin: 1.75rem 0 0.75rem; color: #0a0a0a; }
#blog_body h2   { font-size: 1.25rem; font-weight: 700; margin: 1.5rem 0 0.65rem; color: #111; }
#blog_body h3   { font-size: 1.05rem; font-weight: 600; margin: 1.25rem 0 0.5rem; color: #111; }
#blog_body hr   { border: none; border-top: 1px solid rgba(0,0,0,0.1); margin: 1.5rem 0; }
#blog_body img  { max-width: 100%; height: auto; border-radius: 4px; margin: 1rem 0; display: block; }

/* pull in dark text from email-formatted HTML; set links to a readable dark blue */
#blog_body *   { color: #1a1a1a; }
#blog_body a   { color: #1a4a9a !important; text-decoration: none; transition: color 0.2s; }
#blog_body a:hover { color: #0033cc !important; text-decoration: underline; }

#blog_body .blog_title  { color: #0a0a0a !important; }
#blog_body .post-year   { color: #8b1a1a !important; }

.clickable {
  cursor: pointer;
  color: #8b1a1a !important;
}

/* ── PERMALINK AREA ───────────────────────────────────────────────────────── */

#permalink {
  color: rgba(0, 0, 0, 0.38);
  font-size: 0.82rem;
  font-family: monospace;
}

#preview_area a { color: #1a4a9a !important; }

/* ── PATENTS ──────────────────────────────────────────────────────────────── */

.patent-meta {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.patent-num {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.patent-num a {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1a4a9a !important;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.patent-num a:hover { text-decoration: underline; }

.patent-badge {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6b4a00;
  background: #fff3cd;
  border: 1px solid #e6c96e;
  border-radius: 3px;
  padding: 0.2rem 0.55rem;
}

.patent-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.2rem 1.25rem;
  margin: 0;
}

.patent-dl dt {
  font-size: 0.76rem;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.42);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  padding: 0.1rem 0;
}

.patent-dl dd {
  font-size: 0.83rem;
  color: #2a2a2a;
  margin: 0;
  padding: 0.1rem 0;
}

.patent-abstract {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #1a1a1a;
  max-width: 700px;
  margin-bottom: 1.5rem;
}

.patent-view-link {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 500;
  color: #1a4a9a !important;
  text-decoration: none;
  border: 1px solid rgba(26, 74, 154, 0.28);
  border-radius: 4px;
  padding: 0.35rem 0.85rem;
  transition: background 0.2s, border-color 0.2s;
}

.patent-view-link:hover {
  background: rgba(26, 74, 154, 0.06);
  border-color: rgba(26, 74, 154, 0.5);
  text-decoration: none !important;
}

/* Patent body — section headings, claims, figure grid */

#blog_body .patent-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.38) !important;
  margin: 2rem 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.09);
}

.patent-summary {
  font-size: 0.95rem;
  line-height: 1.82;
  color: #1a1a1a;
  max-width: 700px;
  margin-bottom: 0.25rem;
}

.patent-claims {
  font-size: 0.87rem;
  line-height: 1.72;
  color: #2a2a2a;
  max-width: 700px;
  padding-left: 1.4rem;
  margin: 0 0 0.25rem;
}

.patent-claims li { margin-bottom: 0.65rem; }

.patent-figures {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.6rem;
  margin: 0.5rem 0 1.25rem;
}

.patent-figure {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.patent-figure img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 640px) {
  .patent-figures { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ── FACEBOOK POSTS ───────────────────────────────────────────────────────── */

/* Rich link-preview card (shown when OG image is available) */

.fb-link-preview {
  display: flex;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none !important;
  margin: 0.75rem 0;
  color: inherit;
  transition: background 0.15s;
  max-width: 560px;
}

.fb-link-preview:hover { background: rgba(0, 0, 0, 0.03); }

.fb-link-preview-img {
  width: 130px;
  min-height: 90px;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}

.fb-link-preview-info {
  padding: 0.65rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  justify-content: center;
}

.fb-link-preview-domain {
  font-size: 0.7rem;
  color: rgba(0, 0, 0, 0.42);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fb-link-preview-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.fb-link-preview-desc {
  font-size: 0.78rem;
  color: rgba(0, 0, 0, 0.52);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

@media (max-width: 640px) {
  .fb-link-preview-img { width: 90px; min-height: 70px; }
  .fb-link-preview-desc { display: none; }
}

.fb-link {
  margin: 0.75rem 0;
  padding: 0.6rem 0.875rem;
  background: rgba(0, 0, 0, 0.04);
  border-left: 3px solid rgba(0, 0, 0, 0.15);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  word-break: break-all;
}

.fb-link a { color: #1a4a9a !important; }

.fb-place {
  margin: 0.75rem 0;
  font-size: 0.85rem;
  color: rgba(0, 0, 0, 0.55);
}

.fb-photo-single {
  margin: 1rem 0;
}

.fb-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

.fb-photo {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 4px;
  overflow: hidden;
}

.fb-photo img {
  width: 100%;
  height: auto;
  display: block;
}

.fb-caption {
  font-size: 0.82rem;
  color: rgba(0, 0, 0, 0.55);
  padding: 0.4rem 0.6rem;
  margin: 0;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .fb-photos { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ── BLOG INDEX / BROWSE LIST ─────────────────────────────────────────────── */

#blog_index {
  margin-top: 2rem;
  padding: 1.5rem 1.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  max-height: 55vh;
  overflow-y: auto;
  font-size: 0.84rem;
  line-height: 2.1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.ind {
  display: block;
  padding-left: 0;
}

#blog_index a {
  color: rgba(100, 160, 255, 0.75);
  text-decoration: none;
}
#blog_index a:hover {
  color: var(--white);
  text-decoration: underline;
}

/* ── SCROLL ARROWS ────────────────────────────────────────────────────────── */

.scroll-arrow {
  display: none;           /* JS adds .visible to show */
  position: fixed;
  top: 50vh;
  transform: translateY(-50%);
  z-index: 200;
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  color: #fff;
  text-shadow: 0 0 4px rgba(0,0,0,0.7), 0 1px 4px rgba(0,0,0,0.5);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: text-shadow 0.18s;
  padding: 0;
}

.scroll-arrow.visible { display: flex; }

#scroll-up   { left:  max(8px, calc(50vw - 475px)); }
#scroll-down { right: max(8px, calc(50vw - 475px)); }

.scroll-arrow:hover {
  text-shadow: 0 0 8px rgba(0,0,0,0.9), 0 1px 6px rgba(0,0,0,0.7);
}

/* ── SEARCH HIGHLIGHT ─────────────────────────────────────────────────────── */

mark.search-highlight {
  background: #ffe566;
  color: #1a1a1a !important;
  border-radius: 2px;
  padding: 0 1px;
  font-style: inherit;
  font-weight: inherit;
}

mark.search-highlight-current {
  background: #ff9500;
  color: #fff !important;
}

/* ── SEARCH BAR ───────────────────────────────────────────────────────────── */

#search-bar {
  background: rgba(10, 10, 10, 0.97);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.search-bar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0.6rem 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-case-label {
  display: none;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 1);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.search-case-label.visible { display: flex; }

.search-case-label input[type="checkbox"] {
  cursor: pointer;
  accent-color: #fff;
  width: 13px;
  height: 13px;
}

.search-wrap {
  position: relative;
  width: 180px;
}

#search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  padding: 0.42rem 2.1rem 0.42rem 0.9rem;
  font-family: var(--font);
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 1);
  outline: none;
  transition: background 0.2s, border-color 0.2s;
  box-sizing: border-box;
}

#search-input::placeholder { color: rgba(255, 255, 255, 0.28); }

#search-input:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}

#search-clear {
  display: none;
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.38);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  transition: color 0.15s;
}

#search-clear:hover { color: rgba(255, 255, 255, 0.8); }

/* ── SEARCH RESULTS ────────────────────────────────────────────────────────── */

.sr-header {
  padding: 1rem 1.25rem 0.8rem;
  font-size: 0.82rem;
  color: rgba(0, 0, 0, 0.52);
  border-bottom: 1px solid rgba(0, 0, 0, 0.09);
}

.sr-header strong { color: #1a1a1a; }
.sr-header em     { color: #8b1a1a; font-style: italic; }

.sr-loading {
  font-size: 0.75rem;
  color: rgba(0, 0, 0, 0.35);
}

.sr-empty {
  padding: 2.5rem 1.25rem;
  color: rgba(0, 0, 0, 0.38);
  font-size: 0.88rem;
  text-align: center;
}

.sr-table {
  width: 100%;
  border-collapse: collapse;
}

.sr-row {
  cursor: pointer;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  transition: background 0.1s;
}

.sr-row:hover     { background: rgba(0, 0, 0, 0.04); }
.sr-row:last-child { border-bottom: none; }

.sr-table td { padding: 0.58rem 0.75rem; vertical-align: middle; }

.sr-count {
  width: 32px;
  text-align: right;
  font-size: 0.76rem;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.22);
  white-space: nowrap;
  padding-right: 0.2rem !important;
}

.sr-count-many { color: #8b1a1a; }

.sr-src { width: 90px; white-space: nowrap; }

.sr-badge {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 3px;
  padding: 0.18rem 0.45rem;
  white-space: nowrap;
}

.sr-badge-newsletter { background: #ede9fe; color: #4c1d95; }
.sr-badge-blogger    { background: #dcfce7; color: #166534; }
.sr-badge-facebook   { background: #dbeafe; color: #1e40af; }
.sr-badge-pubs       { background: #fef3c7; color: #92400e; }

.sr-date {
  width: 66px;
  font-size: 0.76rem;
  color: rgba(0, 0, 0, 0.38);
  white-space: nowrap;
  font-family: monospace;
}

.sr-title {
  font-size: 0.87rem;
  color: #1a1a1a;
  line-height: 1.4;
}

/* ── RESPONSIVE ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .page-hero { padding: 9rem 1.5rem 3rem; }
  .writing-main { padding: 2rem 1.25rem 4rem; }
  .section-tabs-inner { padding: 0 1rem; }
  .section-tab { padding: 0.875rem 0.875rem; font-size: 0.72rem; }
  .post-nav { padding: 0.75rem 1.25rem; gap: 0.5rem; }
  .post-nav-text-btn:not(.post-nav-browse) { display: none; }
  .post-nav-sep { display: none; }
  #preview_area { padding: 1.75rem 1.5rem 1.5rem; }
  .search-bar-inner { padding: 0.5rem 1.25rem; }
  .sr-table td { padding: 0.5rem 0.5rem; }
  .sr-src { width: 74px; }
  .sr-date { width: 54px; font-size: 0.7rem; }
  .sr-title { font-size: 0.82rem; }
}
