@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url(/local/fonts/cormorant-garamond-italic-300.ttf) format('truetype');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/local/fonts/cormorant-garamond-italic-400.ttf) format('truetype');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(/local/fonts/cormorant-garamond-normal-300.ttf) format('truetype');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/local/fonts/cormorant-garamond-normal-400.ttf) format('truetype');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/local/fonts/cormorant-garamond-normal-700.ttf) format('truetype');
}

/* Cream light palette with inverted colors on a charcoal dark background. */
:root {
  color-scheme: light;
  --page: #F5F0E6;
  --surface: #F0F1F2;
  --surface-elevated: #DCE2E7;
  --ink: #303840;
  --muted: #566573;
  --text-muted: #667687;
  --line: #C8CFD6;
  --primary: #435B75;
  --accent: #718AA3;
  --accent-muted: #A8B9C8;
  --link: #435B75;
  --hover: #303840;
  --focus: #435B75;
  --button-text: #F0F1F2;
  --button-hover: #303840;
  --selection-bg: #A8B9C8;
  --selection-text: #303840;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #1B1F22;
  --surface: #0F0E0D;
  --surface-elevated: #231D18;
  --ink: #CFC7BF;
  --muted: #A99A8C;
  --text-muted: #998978;
  --line: #373029;
  --primary: #BCA48A;
  --accent: #8E755C;
  --accent-muted: #574637;
  --link: #BCA48A;
  --hover: #CFC7BF;
  --focus: #BCA48A;
  --button-text: #0F0E0D;
  --button-hover: #CFC7BF;
  --selection-bg: #574637;
  --selection-text: #CFC7BF;
}

html,
body {
  min-height: 100%;
  background: var(--page);
  color: var(--ink);
}

body {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 300;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-text);
}

body a,
body a:visited,
body h1 a,
body header h2 a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

body a:hover {
  color: var(--hover);
}

/* Keep post titles distinct from body text without recoloring owner actions. */
body .post-title a.u-url:link,
body .post-title a.u-url:visited {
  color: var(--link);
}

body .post-title a.u-url:hover,
body .post-title a.u-url:focus-visible {
  color: var(--hover);
}

:root:not([data-theme="dark"]) body .post-title a.u-url {
  color: #000000;
}

:root[data-theme="dark"] body .post-title a.u-url {
  color: #FFFFFF;
}

body h1, body h2, body h3 {
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

body#collection > header,
body#post > header,
body#subpage > header {
  box-sizing: border-box;
  width: calc(100% - 3rem);
  max-width: 42rem;
  margin: clamp(3rem, 10vw, 7rem) auto 3.5rem;
  padding: 0 0 2rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
  opacity: 1;
}

body #blog-title {
  display: block;
  font-size: clamp(1.65rem, 4vw, 2.4rem);
  margin: 0;
  font-weight: 700;
}

body #blog-title a {
  color: var(--ink);
  text-decoration: none;
}

body header p.description {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
  margin: 1rem 0 0;
}

body#collection #wrapper,
body#subpage #wrapper,
body#post article#post-body {
  box-sizing: border-box;
  width: calc(100% - 3rem);
  max-width: 42rem;
  margin-left: auto;
  margin-right: auto;
}

body#collection article,
body#subpage article,
body#post article#post-body {
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 300;
  overflow-wrap: anywhere;
}

body#collection article.norm,
body#collection article.sans,
body#subpage article.norm,
body#subpage article.sans,
body#post article#post-body.norm,
body#post article#post-body.sans {
  font-family: "Cormorant Garamond", Georgia, serif;
}

body#collection article p,
body#subpage article p,
body#post article#post-body {
  line-height: 1.8;
}

body article time,
body#post article time.dt-published,
body#collection #wrapper time,
body#subpage #wrapper time {
  color: var(--muted);
  font: 300 0.9rem/1.6 "Cormorant Garamond", Georgia, serif;
}

body blockquote {
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 1.2rem;
}

body pre,
body code,
body .hljs {
  background: var(--surface);
}

body pre {
  padding: 1rem;
  overflow-x: auto;
  border-radius: 4px;
}

body article img,
body article video {
  max-width: 100%;
  height: auto;
}

body hr {
  background: var(--line);
  height: 1px;
}

body > footer {
  max-width: 42rem;
  margin: 4rem auto 2rem;
  font-size: 0.8rem;
  box-sizing: border-box;
}

body footer nav,
body footer nav a:link,
body footer nav a:visited {
  color: var(--muted);
}

body input,
body textarea,
body textarea:focus,
body select {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: none;
}

body input::placeholder,
body textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

body button,
body input[type="submit"],
body .btn {
  background: var(--primary);
  color: var(--button-text);
  border: 1px solid var(--primary);
  border-radius: 4px;
  box-shadow: none;
  text-shadow: none;
}

body button:hover,
body input[type="submit"]:hover,
body .btn:hover {
  background: var(--button-hover);
  color: var(--button-text);
}

body :is(a, button, input, textarea, select):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

body button#theme-toggle {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  min-height: 44px;
  width: 44px;
  height: 44px;
  padding: 10px;
  display: grid;
  place-items: center;
  background: var(--page);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: 400 1rem/1.2 "Cormorant Garamond", Georgia, serif;
  cursor: pointer;
}

body button#theme-toggle:hover {
  background: var(--surface);
  color: var(--ink);
}

body button#theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:root[data-theme="dark"] body .hljs {
  color: var(--ink);
}

/* Hide only the legacy management menu, not pinned-post links. */
body#collection > nav#manage {
  display: none !important;
}

body#collection > header > nav,
body#post > header > nav,
body#subpage > header > nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  margin: 1.25rem 0 0;
  font-size: 1rem;
  line-height: 1.5;
}

body#collection > header > nav a.pinned,
body#post > header > nav a.pinned,
body#subpage > header > nav a.pinned {
  margin: 0;
  color: var(--link);
  text-decoration: underline;
  overflow-wrap: anywhere;
}

/* This menu is rendered by the server only for the authenticated blog owner. */
body nav#owner-menu {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 20;
  font: 400 1.1rem/1.5 "Cormorant Garamond", Georgia, serif;
}

#owner-menu summary {
  box-sizing: border-box;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--page);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

#owner-menu summary::-webkit-details-marker { display: none; }

#owner-menu summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

#owner-menu .owner-menu-links {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 11rem;
  max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  padding: 6px;
  background: var(--surface-elevated);
  border: 1px solid var(--line);
  border-radius: 6px;
}

#owner-menu .owner-menu-links a {
  display: block;
  padding: 8px 12px;
  color: var(--link);
  text-decoration: none;
}

#owner-menu .owner-menu-links a:hover {
  background: var(--surface);
}

/* The writing screens use the same palette and preference as the blog. */
html[data-theme] body:is(#pad, #pad-sub),
html[data-theme] body:is(#pad, #pad-sub) :is(#writer, #editor, #title, .ProseMirror, .modal, #tools) {
  background: var(--page);
  color: var(--ink);
  border-color: var(--line);
}

html[data-theme] body:is(#pad, #pad-sub) #tools nav ul ul {
  background: var(--surface-elevated);
  border-color: var(--line);
}

html[data-theme] body:is(#pad, #pad-sub) #tools :is(a, button, li.menu-heading, #wc, #status) {
  color: var(--ink);
}

html[data-theme] body:is(#pad, #pad-sub) #tools nav ul li:hover {
  background: var(--surface);
}

html[data-theme] body:is(#pad, #pad-sub) .modal :is(input, textarea, select) {
  background: var(--surface);
  color: var(--ink);
}

html[data-theme] body:is(#pad, #pad-sub) .modal :is(a, .form-hint) {
  color: var(--muted);
}

/* Color-only overrides for WriteFreely's built-in controls and states. */
body .dropdown-nav ul ul,
body .modal {
  background-color: var(--surface-elevated);
  color: var(--ink);
  border-color: var(--line);
}

body .dropdown-nav ul a,
body#me #official-writing h2 a:link,
body#me #official-writing h2 a:visited {
  color: var(--link);
}

body .dropdown-nav ul li:hover,
body nav#admin a.selected,
body .pager a.selected {
  background-color: var(--surface-elevated);
  color: var(--ink);
}

body .dropdown-nav ul li.selected a,
body .dropdown-nav ul li.menu-heading,
html[data-theme] body:is(#pad, #pad-sub) #tools nav ul li.selected a {
  color: var(--muted);
}

body article table :is(th, td) {
  border-color: var(--line);
}

body .alert:is(.info, .success, .danger) {
  background-color: var(--surface-elevated);
  border-color: var(--accent-muted);
  color: var(--ink);
}

body .alert.danger h3 { color: var(--ink) !important; }

body :is(button, input, select, textarea, a.btn):disabled,
body .btn.cta.disabled {
  background-color: var(--surface-elevated) !important;
  border-color: var(--line) !important;
  color: var(--text-muted);
}

body #collection-options .option label.option-text.disabled,
body table.classy.export .disabled {
  color: var(--text-muted);
}

body .pager.sub a:not(.toggle).selected {
  color: var(--link);
  border-bottom-color: var(--accent);
}

/* Reserve space for the shared toggle beside the editor toolbar. */
body:is(#pad, #pad-sub) #tools { padding-left: 4.5rem; }
body:is(#pad, #pad-sub) #toggle-theme { display: none; }

/* Mobile: 44px controls at 0.75rem from the top, then a 50px title gap. */
@media (max-width: 600px) {
  body#collection article,
  body#subpage article,
  body#post article#post-body {
    font-size: 1rem;
  }

  body#collection > header,
  body#post > header,
  body#subpage > header {
    margin-top: calc(0.75rem + 44px + 50px);
  }
}
