/* notes pages: shared styles. palette comes from style.css tokens only. */

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

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

/* ── page head ── */
.page-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

main > section:first-of-type h1 {
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}

main > section:first-of-type h1::before {
  content: "~/";
  color: var(--accent);
  margin-right: 0.15em;
}

#fn-status:empty { display: none; }

/* ── gate ── */
.fn-gate {
  display: flex;
  justify-content: flex-start;
  margin: 0 0 3rem;
}

#fn-form {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  max-width: 24rem;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

#fn-form:focus-within { border-color: var(--accent); }

#fn-form::before {
  content: "$";
  color: var(--accent);
  flex: none;
}

#fn-form label {
  color: var(--muted);
  font-size: 0.85rem;
  flex: none;
}

#fn-code {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  padding: 0;
  outline: none;
  caret-color: var(--accent);
}

.fn-gate.shake #fn-form {
  border-color: var(--danger);
  animation: fn-shake 0.35s;
}

@keyframes fn-shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ── vault layout (explorer left, note right) ── */
main:has(#fn-app:not([hidden])) { max-width: 1120px; }

#fn-app {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  align-items: start;
  margin-bottom: 0;
  border: 1px solid var(--border);
  min-height: 60vh;
}

#fn-side {
  position: sticky;
  top: 1rem;
  align-self: start;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.8rem 0.6rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

#fn-list {
  flex: 1 1 auto;
  min-height: 6rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#fn-pane { --fn-col: 39.6rem; padding: 2rem 2.5rem 3rem; min-width: 0; }

#fn-empty {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

#fn-note .post-back { display: none; }

/* ── note index ── */


.fn-tree { list-style: none; }

.fn-tree .fn-tree {
  margin: 0.15rem 0 0.5rem 0.55rem;
  padding-left: 0.9rem;
  border-left: 1px solid var(--border);
}

.fn-tree li { margin: 0; }

.fn-tree summary {
  display: block;
  padding: 0.3rem 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color 0.15s, background-color 0.15s;
}

.fn-tree summary::-webkit-details-marker { display: none; }

.fn-tree summary::before {
  content: "▸";
  display: inline-block;
  width: 1.1em;
  color: var(--muted);
  transition: transform 0.15s, color 0.15s;
}

.fn-tree details[open] > summary::before {
  transform: rotate(90deg);
  color: var(--accent);
}

.fn-tree summary:hover {
  color: var(--text);
  background: var(--surface);
}

.fn-tree a {
  display: block;
  padding: 0.3rem 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, background-color 0.15s, border-color 0.15s;
}

.fn-tree a:hover {
  color: var(--link);
  background: var(--surface);
  border-left-color: var(--accent);
  text-decoration: none;
}

.fn-tree a.is-active {
  color: var(--accent);
  background: var(--surface-2);
  border-left-color: var(--accent);
}

/* ── open note ── */
#fn-note { animation: fn-rise 0.35s ease-out both; }

#fn-body h2,
#fn-body h3,
#fn-body h4 {
  color: var(--text);
  letter-spacing: -0.01em;
  margin-top: 2.4rem;
}


#fn-body a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}

#fn-body a:hover { text-decoration-color: var(--link); }

#fn-body strong { color: var(--text); font-weight: 700; }
#fn-body em { color: var(--text); }
#fn-body del { color: var(--muted); }
#fn-body mark { background: transparent; color: var(--accent); }
#fn-body .fn-missing { color: var(--muted); text-decoration: line-through; }

#fn-body hr { margin: 2.4rem 0; }

#fn-body ul,
#fn-body ol { list-style: none; padding-left: 0; }

#fn-body ul li { position: relative; padding-left: 1.2rem; }
#fn-body ul li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--accent);
}

#fn-body ol { counter-reset: fn-ol; }
#fn-body ol li { position: relative; padding-left: 1.8rem; counter-increment: fn-ol; }
#fn-body ol li::before {
  content: counter(fn-ol) ".";
  position: absolute;
  left: 0;
  color: var(--muted);
}

#fn-body li:has(> input[type="checkbox"])::before { content: none; }
#fn-body li:has(> input[type="checkbox"]) { padding-left: 0; }

#fn-body input[type="checkbox"] {
  appearance: none;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.5em;
  border: 1px solid var(--muted);
  vertical-align: -0.1em;
  background: transparent;
}

#fn-body input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── obsidian extras ── */
#fn-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--border);
  padding: 0.9rem 1.1rem;
  overflow: visible;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
}

#fn-body pre code { font-size: 0.82rem; color: var(--text); }

#fn-body a { overflow-wrap: anywhere; }

#fn-body a[data-file] {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  font-size: 0.85em;
}

#fn-body a[data-file]:hover { border-color: var(--link); }
#fn-body a[data-file]::before { content: "↗ "; color: var(--muted); }

.fn-tag {
  display: inline-block;
  padding: 0 0.45rem;
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.8em;
}

.fn-callout {
  --co: var(--muted);
  border: 1px solid var(--border);
  border-left: 2px solid var(--co);
  background: var(--surface);
  padding: 0.8rem 1.1rem;
}

.fn-callout[data-kind="info"],
.fn-callout[data-kind="note"],
.fn-callout[data-kind="abstract"],
.fn-callout[data-kind="todo"],
.fn-callout[data-kind="quote"] { --co: var(--link); }

.fn-callout[data-kind="tip"],
.fn-callout[data-kind="success"],
.fn-callout[data-kind="check"],
.fn-callout[data-kind="done"],
.fn-callout[data-kind="example"] { --co: var(--accent); }

.fn-callout[data-kind="warning"],
.fn-callout[data-kind="caution"],
.fn-callout[data-kind="danger"],
.fn-callout[data-kind="error"],
.fn-callout[data-kind="bug"],
.fn-callout[data-kind="failure"] { --co: var(--danger); }

.fn-callout-title {
  color: var(--co);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.fn-callout-body > * + * { margin-top: 0.7rem; }
.fn-callout-body ul, .fn-callout-body ol { margin-top: 0.4rem; }

/* ── tables ── */
.fn-table {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.fn-table table {
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 100%;
}

.fn-table th,
.fn-table td {
  padding: 0.5rem 1rem 0.5rem 0;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.fn-table th {
  color: var(--muted);
  font-weight: 400;
  border-bottom-color: var(--muted);
}

/* ── article layout ── */
.fn-head {
  width: min(var(--fn-col), 100%);
  margin: 0 auto 2.4rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--border);
}

#fn-kicker {
  margin: 0 0 0.9rem;
  color: var(--accent);
  font-size: 0.82rem;
  max-width: none;
}

#fn-title {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: clamp(1.7rem, 3.6vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-transform: none;
  color: var(--text);
}

#fn-meta {
  margin: 1.1rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  max-width: none;
}

#fn-meta:empty { display: none; }

#fn-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, var(--fn-col)) minmax(0, 1fr);
  max-width: none;
  font-size: 1rem;
  line-height: 1.8;
}

#fn-body > * { grid-column: 2; }
#fn-body > .fn-table,
#fn-body > .fn-fig[data-size="wide"] { grid-column: 1 / -1; }

#fn-body .fn-lead {
  font-size: 1.2rem;
  line-height: 1.6;
  letter-spacing: -0.01em;
}

#fn-body h2 {
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-top: 3rem;
}

#fn-body h2::before {
  content: "";
  display: block;
  width: 2rem;
  height: 2px;
  margin-bottom: 0.8rem;
  background: var(--accent);
}

#fn-body h3 { font-size: 1.15rem; line-height: 1.3; margin-top: 2.2rem; }
#fn-body h4 { font-size: 0.95rem; color: var(--muted); margin-top: 1.8rem; }

#fn-body blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.1rem 0 0.1rem 1.3rem;
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--text);
}

/* ── figures sized from the picture itself ── */
.fn-fig {
  margin: 0;
  opacity: 0;
  transition: opacity 0.35s;
}

.fn-fig.is-loaded { opacity: 1; }
#fn-body > .fn-fig { margin: 1.6rem 0; }

.fn-fig img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
}

.fn-fig[data-size="small"],
.fn-fig[data-size="medium"] { max-width: min(var(--w), 100%); }

.fn-fig[data-size="tall"] { max-width: min(var(--w), 100%); justify-self: center; }
.fn-fig[data-size="tall"] img { width: auto; max-width: 100%; max-height: 75vh; margin-inline: auto; }

.fn-fig figcaption {
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ── motion ── */
@keyframes fn-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  #fn-note, .fn-gate.shake #fn-form { animation: none; }
  .fn-tree summary::before { transition: none; }
}

/* ── phone ── */
@media (max-width: 760px) {
  #fn-app { grid-template-columns: 1fr; border: 0; min-height: 0; }
  #fn-side { position: static; max-height: none; border: 1px solid var(--border); }
  #fn-list { max-height: 55vh; }
  #fn-pane { padding: 0; }
  #fn-empty { display: none; }
  #fn-app.has-note #fn-side { display: none; }
  #fn-note .post-back { display: inline-block; margin: 0 0 1.6rem; }
  #fn-body { display: block; font-size: 0.95rem; }
  #fn-body .fn-lead { font-size: 1.1rem; }
}

@media (max-width: 520px) {
  #fn-form { max-width: none; }
}

.fn-i1 { margin-left: 1.2rem; }
.fn-i2 { margin-left: 2.4rem; }
.fn-i3 { margin-left: 3.6rem; }
.fn-i4 { margin-left: 4.8rem; }

.fn-link-off { color: var(--link); opacity: .55; cursor: not-allowed; }

/* ── order switch and dates ── */
.fn-view {
  flex: none;
  display: flex;
  gap: 0.4rem;
  margin: 0 0 0.9rem;
}

#fn-side .fn-view button {
  flex: 1;
  padding: 0.25rem 0.5rem;
  color: var(--muted);
}

#fn-side .fn-view button[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
}

.fn-flat a { padding: 0.45rem 0.5rem; }
.fn-name { display: block; overflow-wrap: anywhere; }

.fn-sub {
  display: block;
  margin-top: 0.1rem;
  color: var(--muted);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.fn-date {
  margin-left: 0.6rem;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* ── sharing ── */
#fn-side button,
.fn-share-row button {
  padding: 0.2rem 0.7rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

#fn-side button:hover,
#fn-side button:focus-visible,
.fn-share-row button:hover,
.fn-share-row button:focus-visible {
  border-color: var(--accent);
  color: var(--link);
}

#fn-side button:disabled,
.fn-share-row button:disabled { color: var(--muted); cursor: default; border-color: var(--border); }

.fn-share-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

#fn-share-status { min-width: 0; overflow-wrap: anywhere; }

#fn-share-status input,
.fn-share-msg input {
  width: min(22rem, 100%);
  padding: 0.2rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
}

#fn-share-status input:focus,
.fn-share-msg input:focus { border-color: var(--accent); outline: none; }

#fn-shares {
  flex: none;
  max-height: 11rem;
  overflow-y: auto;
  margin-bottom: 0.9rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#fn-shares h3 {
  margin: 0 0 0.5rem;
  padding: 0 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

#fn-shares-list { list-style: none; margin: 0; padding: 0; }

#fn-shares-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.5rem;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.fn-share-name { flex: 1 1 100%; color: var(--text); overflow-wrap: anywhere; }
.fn-share-info { flex: 1 1 100%; color: var(--muted); font-size: 0.75rem; }
.fn-share-actions { display: flex; gap: 0.4rem; }
.fn-share-msg { flex: 1 1 100%; min-width: 0; color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
.fn-share-msg:empty { display: none; }
.fn-share-msg input { width: 100%; }
