/*
Theme Name: Reading Today Responsive 4.7
Theme URI: http://reading.today/
Author: Reading Today
Description: A minimal vertical-reading WordPress theme for traditional Chinese essays.
Version: 4.7
Text Domain: reading-today
*/

:root {
  --rt-text: #1f2933;
  --rt-muted: #6b7280;
  --rt-bg: #ffffff;
  --rt-line: #d8d8d8;
  --rt-accent: #111827;
  --rt-narrow-title-width: clamp(68px, 18vw, 76px);
  --rt-reading-gap: clamp(0.5rem, 2vw, 0.9rem);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  overflow-y: auto;
  font-size: 16px;
}

html.rt-single-page {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  overflow-y: auto;
  background: var(--rt-bg);
  color: var(--rt-text);
  font-family:
    "Noto Serif TC",
    "Source Han Serif TC",
    "PingFang TC",
    "Microsoft JhengHei",
    serif;
  line-height: 1.8;
}

body:not(.single-post) {
  min-height: 100%;
  overflow-y: auto;
}

a { color: inherit; text-decoration: none; }
a:hover { color: #007acc; }
img { max-width: 100%; height: auto; }
.rt-site { min-height: 100vh; }

.rt-header {
  display: flex;
  align-items: baseline;
  gap: 2.2rem;
  padding: 0.55rem 4vw 0.35rem;
}

.rt-site-title {
  margin: 0;
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.rt-site-description { display: none; }

.rt-primary-nav {
  margin-top: 0;
  font-family:
    "Noto Serif TC",
    "Source Han Serif TC",
    "PingFang TC",
    "Microsoft JhengHei",
    serif;
  font-size: 0.95rem;
  line-height: 1.2;
  letter-spacing: 0.12em;
}

.rt-menu {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rt-menu li { margin: 0; padding: 0; }
.rt-menu a { color: var(--rt-muted); }
.rt-menu a:hover,
.rt-menu .current-menu-item > a,
.rt-menu .current-post-ancestor > a,
.rt-menu .current-category-ancestor > a { color: var(--rt-text); }

.rt-main { padding: 2rem 6vw 5rem; }
.rt-list { max-width: 760px; margin: 0 auto; }
.rt-list-item { border-bottom: 1px solid var(--rt-line); padding: 2rem 0; }
.rt-list-title { margin: 0 0 0.5rem; font-size: 1.8rem; }
.rt-list-meta { margin-bottom: 1rem; color: var(--rt-muted); font-size: 0.9rem; }
.rt-list-excerpt { color: #374151; }

.rt-single {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  grid-template-areas: "content title";
  column-gap: 1.4rem;
  align-items: start;
  justify-content: center;
  max-width: 1120px;
  min-height: 78vh;
  margin: 0 auto;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rt-line);
}

.rt-reading-viewport { grid-area: content; container-type: inline-size; }

.rt-single-content {
  display: inline-block;
  width: max-content;
  max-width: none;
  max-height: 78vh;
  padding: 0 1rem;
  overflow: visible;
  writing-mode: vertical-rl;
  -webkit-writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 20px;
  line-height: 2.15;
  letter-spacing: 0.04em;
  transform: translateX(0);
  transition: transform 260ms cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: transform;
}

.rt-single-content::after { content: ""; display: inline-block; width: 8rem; height: 100%; }
.rt-single-content p { margin: 0 0 0 1.8em; }
.rt-single-content blockquote,
.rt-single-content .wp-block-quote {
  display: inline-block;
  width: auto;
  height: auto;
  margin: 0 0 0 1.1em;
  padding: 0.8em 0.7em 0.7em;
  border: none;
  border-top: 4px solid var(--rt-accent);
  background: #f5f5f3;
  color: var(--rt-text);
  font-style: normal !important;
  line-height: 2.05;
}

.rt-single-content blockquote *,
.rt-single-content .wp-block-quote * { font-style: normal !important; }
.rt-single-content blockquote p,
.rt-single-content .wp-block-quote p { margin: 0; padding: 0; }
.rt-single-content h2,
.rt-single-content h3,
.rt-single-content h4 { margin: 0 0 0 1.6em; line-height: 1.6; letter-spacing: 0.08em; }
.rt-single-content figure,
.rt-single-content figcaption,
.rt-single-content img,
.rt-single-content table,
.rt-single-content pre,
.rt-single-content code,
.rt-single-content iframe,
.rt-single-content video { writing-mode: horizontal-tb; text-orientation: mixed; }
.rt-single-content pre { max-width: 520px; overflow: auto; padding: 1rem; border: 1px solid var(--rt-line); background: #f8f8f8; line-height: 1.6; }
.rt-single-content code { font-family: "Noto Serif TC", "Source Han Serif TC", serif; font-size: 0.9em; }
.rt-single-content pre,
.rt-single-content table { display: block; width: max-content; max-width: calc(100cqw - 1.5rem); overflow-x: auto; overflow-y: hidden; }
.rt-single-content iframe,
.rt-single-content video { display: inline-block; width: min(560px, calc(100cqw - 1.5rem)); max-width: calc(100cqw - 1.5rem); height: auto; aspect-ratio: 16 / 9; }

.rt-record-cover {
  display: inline-block;
  writing-mode: horizontal-tb !important;
  -webkit-writing-mode: horizontal-tb !important;
  width: min(420px, 82vw, 62vh);
  margin: 0 0 0 2.5rem;
  padding: 0;
  vertical-align: top;
}

.rt-record-cover-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0;
  background: #f2f1ee;
  border: 1px solid rgba(50, 48, 44, 0.08);
  overflow: hidden;
}

.rt-record-cover-frame img {
  position: absolute;
  top: 6%;
  left: 50%;
  width: 88%;
  height: auto;
  margin: 0;
  transform: translateX(-50%);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.rt-record-release {
  width: 100%;
  margin: 8px 0 0;
  padding: 0 2px 0 0;
  writing-mode: horizontal-tb !important;
  font-size: clamp(10px, 0.72vw, 11px);
  line-height: 1.35;
  text-align: right;
  white-space: nowrap;
}

.rt-single-header {
  grid-area: title;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 120px;
  min-height: 78vh;
  overflow: hidden;
}

.rt-single-title {
  max-height: calc(100vh - 15rem);
  margin: 0;
  overflow: hidden;
  writing-mode: vertical-rl;
  -webkit-writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 2.3rem;
  line-height: 1.32;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.rt-single-meta {
  width: 120px;
  margin: 1rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--rt-line);
  color: var(--rt-muted);
  writing-mode: horizontal-tb !important;
  text-orientation: mixed;
  font-family:
    "Noto Serif TC",
    "Source Han Serif TC",
    "PingFang TC",
    "Microsoft JhengHei",
    serif;
  font-size: 0.82rem;
  line-height: 1.8;
}

.rt-single-meta *,
.rt-single-meta div,
.rt-single-meta a { writing-mode: horizontal-tb !important; text-orientation: mixed; }
.rt-single-meta div { margin-bottom: 0.35rem; }
.rt-single-back { margin-top: 1.5rem; }
.rt-footer { padding: 3rem 6vw; color: var(--rt-muted); font-size: 0.85rem; }
.byline, .author, .vcard, .entry-author, .post-author, .rt-author { display: none !important; }

.rt-scroll-btn {
  position: fixed;
  top: 50%;
  z-index: 20;
  width: 2.4rem;
  height: 5.6rem;
  border: none;
  background: transparent;
  color: rgba(31, 41, 51, 0.28);
  font-family: Georgia, serif;
  font-size: 3rem;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-50%);
  transition: color 0.2s ease, background 0.2s ease;
}

.rt-scroll-btn:hover { color: rgba(31, 41, 51, 0.72); background: rgba(0, 0, 0, 0.025); }
.rt-scroll-left { left: 2.2vw; }
.rt-scroll-right { right: 2.2vw; }

@media screen and (min-width: 1025px) {
  body.single-post { height: 100vh; overflow: hidden; }
  body.single-post .rt-site { height: 100vh; overflow: hidden; }
  body.single-post .rt-footer { display: none; }
  body.single-post .rt-main { height: calc(100vh - 3.4rem); padding: 0.35rem 4vw 0.6rem; overflow: hidden; }
  body.single-post .rt-single { height: calc(100vh - 4.4rem); min-height: 0; max-height: calc(100vh - 4.4rem); padding-top: 0.7rem; padding-bottom: 0.4rem; overflow: hidden; }
  body.single-post .rt-reading-viewport { position: relative; height: calc(100vh - 7.2rem); max-height: calc(100vh - 7.2rem); max-width: calc(100vw - 260px); padding: 0 0.5rem 0 4rem; overflow: hidden; overscroll-behavior: contain; }
  body.single-post .rt-single-content { height: 100%; max-height: 100%; padding: 0; }
  body.single-post .rt-single-content::after { width: 44px; }
  body.single-post .rt-single-header { height: calc(100vh - 7.2rem); min-height: 0; max-height: calc(100vh - 7.2rem); }
}

@media screen and (max-width: 1024px) {
  body.single-post { height: 100dvh; overflow: hidden; }
  body.single-post .rt-site { display: flex; flex-direction: column; height: 100dvh; min-height: 0; overflow: hidden; }
  .rt-header { display: block; padding: clamp(0.8rem, 3vw, 1.1rem) 5vw; }
  body.single-post .rt-header { flex: 0 0 auto; }
  .rt-primary-nav { margin-top: 0.7rem; }
  .rt-menu { display: flex; flex-wrap: wrap; gap: 0.65rem 1rem; }
  body.single-post .rt-main { flex: 1 1 auto; min-height: 0; padding: 0.35rem 4vw 0.6rem; overflow: hidden; }
  body.single-post .rt-footer { display: none; }
  body.single-post .rt-single { display: grid; grid-template-columns: minmax(0, 1fr) var(--rt-narrow-title-width); grid-template-areas: "content title"; column-gap: var(--rt-reading-gap); height: 100%; min-height: 0; overflow: hidden; border-top: 1px solid var(--rt-line); padding-top: 0.6rem; }
  body.single-post .rt-reading-viewport { grid-area: content; position: relative; min-width: 0; height: 100%; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; overscroll-behavior: contain; scrollbar-width: none; container-type: inline-size; }
  body.single-post .rt-reading-viewport::-webkit-scrollbar { display: none; }
  body.single-post .rt-single-content { display: inline-block; width: max-content; height: 100%; max-height: 100%; writing-mode: vertical-rl; -webkit-writing-mode: vertical-rl; text-orientation: mixed; overflow: visible; font-size: clamp(17px, 2.4vw, 19px); line-height: 2; padding: 0; }
  body.single-post .rt-reading-viewport.rt-dragging .rt-single-content { transition: none !important; }
  body.single-post .rt-reading-viewport:not(.rt-scroll-enhanced) .rt-single-content { transform: none !important; }
  body.single-post .rt-reading-viewport.rt-scroll-enhanced { overflow-x: hidden; touch-action: pan-y; }
  body.single-post .rt-single-header { grid-area: title; width: var(--rt-narrow-title-width); height: 100%; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between; overflow: hidden; }
  body.single-post .rt-single-title {
    width: auto;
    max-width: 2.7em;
    max-height: calc(100% - 8rem);
    margin: 0;
    overflow: hidden;
    white-space: normal;
    writing-mode: vertical-rl;
    -webkit-writing-mode: vertical-rl;
    font-size: clamp(1rem, 4.3vw, 1.35rem);
    line-height: 1.35;
    letter-spacing: 0.1em;
  }
  body.single-post .rt-single-title.rt-single-title-compact {
    width: 2.7em;
    font-size: clamp(13px, 3.6vw, 15px);
    line-height: 1.22;
  }
  body.single-post .rt-single-title:focus-visible { outline: 2px solid var(--rt-accent); outline-offset: -2px; }
  body.single-post .rt-single-meta { width: 100%; margin: 0; padding-top: 0.5rem; border-top: 1px solid var(--rt-line); writing-mode: horizontal-tb !important; font-size: clamp(0.65rem, 2vw, 0.75rem); line-height: 1.55; }
  body.single-post .rt-single-content pre,
  body.single-post .rt-single-content table { display: block; width: max-content; max-width: calc(100cqw - 1.5rem); overflow-x: auto; overflow-y: hidden; }
  body.single-post .rt-single-content iframe,
  body.single-post .rt-single-content video { display: inline-block; width: min(560px, calc(100cqw - 1.5rem)); max-width: calc(100cqw - 1.5rem); height: auto; aspect-ratio: 16 / 9; }
  .rt-record-cover { width: min(76cqw, 52vh); max-width: calc(100cqw - 1.5rem); margin-left: 1.5rem; }
}

@media screen and (max-width: 600px) {
  body.single-post .rt-single-content::after { width: 36px; }
  .rt-scroll-btn { display: none; }
}

.rt-scroll-btn:focus-visible {
  outline: 2px solid var(--rt-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .rt-single-content { transition: none !important; }
}
