/* Frame layout, contrast, focus, and folds for the rebuilt journal. */

[hidden] {
  display: none !important;
}

:root {
  --jn-focus: #1d4ed8;
  --jn-line: #4b453f;
  --jn-text: var(--dx-text);
  --jn-muted: #4b453f;
  --jn-pad: 10px;
  --jn-gap: 8px;
  --jn-row: 44px;
  --jn-tap: 32px;
  --jn-radius: 12px;
  --jn-dot-on: #1d4ed8;
  --jn-dot-off: #475569;
  --jn-ok: #1d4ed8;
  --jn-miss: #334155;
  --jn-unknown: #334155;
  --jn-error: #b91c1c;
  --jn-s0: #1d4ed8;
  --jn-s1: #0f766e;
  --jn-s2: #6d28d9;
  --jn-s3: #a16207;
  --jn-s4: #334155;
  --jn-s5: #0369a1;
  --jn-s6: #4d7c0f;
  --jn-mark-bg: #fef3c7;
  --jn-mark-line: #d97706;
}

html.dark {
  --jn-focus: #93c5fd;
  --jn-line: #d4d4d4;
  --jn-muted: #d4d4d4;
  --jn-dot-on: #93c5fd;
  --jn-dot-off: #cbd5e1;
  --jn-ok: #93c5fd;
  --jn-miss: #cbd5e1;
  --jn-unknown: #cbd5e1;
  --jn-error: #fca5a5;
  --jn-s0: #93c5fd;
  --jn-s1: #5eead4;
  --jn-s2: #d8b4fe;
  --jn-s3: #fcd34d;
  --jn-s4: #cbd5e1;
  --jn-s5: #7dd3fc;
  --jn-s6: #bef264;
  --jn-mark-bg: #5c4010;
  --jn-mark-line: #fbbf24;
}

body.dx,
body.dx *,
body.dx *::before,
body.dx *::after {
  box-sizing: border-box;
}

body.dx {
  max-width: 100%;
}

body.dx * {
  transition: none !important;
}

body.dx,
.dx-card,
.crumbs,
.dx-header,
.info-tip {
  color: var(--dx-text);
}

.dx-header,
.dx-card,
.info-tip,
.skip-link:focus {
  background-color: var(--dx-card-solid);
}

/* Frame: the same header, top bar, hero, and cards as /health/nutrition/. */
.dx-header {
  flex-wrap: wrap;
  row-gap: 4px;
  max-width: 100%;
  background-color: var(--dx-bg);
}

.dx-header .dx-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
  max-width: 46%;
}

#sync-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--jn-muted);
}

#sync-label.is-error {
  color: var(--jn-error);
}

.dx-header .dong-theme-toggle {
  position: static;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  margin: 0;
}

.dx-header .dong-theme-toggle__knob {
  top: 11px;
}

body.dx .dx-header .view-nav {
  flex: 1 0 100%;
  display: flex;
  gap: 4px;
  min-width: 0;
}

body.dx .dx-header .view-nav a {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 44px;
  padding: 0 4px;
  border: 1px solid var(--jn-line);
  border-radius: 999px;
  color: var(--dx-text);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

body.dx .dx-header .view-nav a[aria-current="page"] {
  background: #1d4ed8;
  color: #ffffff;
  border-color: transparent;
}

html.dark body.dx .dx-header .view-nav a[aria-current="page"] {
  background: #60a5fa;
  color: #0d0d0d;
}

body.dx nav.suite-nav {
  width: min(560px, calc(100% - 12px));
  margin: 8px auto 0;
  background: var(--dx-card-solid);
}

body.dx nav.suite-nav > a {
  color: var(--dx-text);
}

body.dx nav.suite-nav > a[aria-current="page"] {
  background: #1d4ed8;
  color: #ffffff;
}

html.dark body.dx nav.suite-nav > a[aria-current="page"] {
  background: #60a5fa;
  color: #0d0d0d;
}

#main,
#connect {
  width: min(720px, calc(100% - 12px));
  margin-left: auto;
  margin-right: auto;
}

#main {
  padding-top: 10px;
  padding-bottom: calc(var(--jn-gap) + env(safe-area-inset-bottom));
}

#main:focus {
  outline: none;
}

.hero {
  margin: 0 0 12px;
  padding: 12px 14px 12px;
  border-radius: 22px;
}

body.dx nav.crumbs {
  margin: 0 0 4px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

body.dx nav.crumbs ol {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

body.dx nav.crumbs ol::-webkit-scrollbar {
  display: none;
}

body.dx nav.crumbs li {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
}

body.dx nav.crumbs li + li::before {
  content: "\203A";
  padding: 0 3px;
  color: var(--jn-muted);
  font-size: 0.75rem;
}

body.dx nav.crumbs a {
  display: inline-flex;
  align-items: center;
  min-width: 24px;
  min-height: 24px;
  padding: 0 2px;
  color: var(--jn-muted);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}

body.dx nav.crumbs a[aria-current="page"] {
  color: var(--dx-text);
  font-weight: 700;
}

.hero-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

#period-heading {
  flex: 1 1 100%;
  min-width: 0;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

#period-heading:focus {
  outline: 3px solid var(--jn-focus);
  outline-offset: 3px;
}

.period-nav {
  display: flex;
  flex: 0 0 auto;
  margin-left: auto;
  gap: 6px;
}

#prev,
#next,
#today {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--jn-line);
  background: var(--dx-card-solid);
  color: var(--dx-text);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
}

#prev,
#next {
  padding: 0;
  font-size: 1.4rem;
  line-height: 1;
}

#today:disabled {
  opacity: 0.5;
  cursor: default;
}

.dx-btn {
  min-height: var(--jn-tap);
  min-width: var(--jn-tap);
  border-color: transparent;
}

.dx-btn--ghost {
  color: var(--dx-text);
  background: var(--dx-card-solid);
  border-color: var(--jn-line);
}

#connect {
  margin-top: 8px;
  margin-bottom: 16px;
}

#connect[hidden] {
  display: none;
}

#btn-connect {
  width: 100%;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  min-width: var(--jn-tap);
  min-height: var(--jn-tap);
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--dx-card-solid);
  color: var(--dx-text);
  font-weight: 700;
  text-decoration: underline;
  transform: translateY(-160%);
  pointer-events: none;
}

.skip-link:focus {
  transform: none;
  pointer-events: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

body.dx :focus-visible {
  outline: 3px solid var(--jn-focus);
  outline-offset: 2px;
}

.dx-header .dong-theme-toggle:focus-visible {
  outline: 3px solid var(--jn-focus);
  outline-offset: 2px;
  box-shadow: none;
}

.fold,
.jn-card {
  margin: 0 0 var(--jn-gap);
  padding: 0;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--dx-radius);
}

.fold-heading {
  margin: 0;
  font-size: 1rem;
}

body.dx .fold > .fold-bar > .fold-heading > .fold-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  height: 44px;
  margin: 0;
  padding: 8px 12px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

body.dx .fold > .fold-bar > .fold-heading > .fold-summary:focus-visible {
  outline-offset: -3px;
}

.fold-summary::after {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  margin-left: 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.fold.is-open > .fold-bar .fold-summary::after {
  transform: translateY(2px) rotate(-135deg);
}

.fold-emoji {
  flex: 0 0 auto;
  font-size: 1rem;
  line-height: 1;
}

.fold-line {
  min-width: 0;
  margin: 0;
  line-height: 1.35;
}

.fold > .fold-bar .fold-line {
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.fold-body {
  min-width: 0;
  padding: 0 12px 12px;
}

.jn-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  padding: 8px 12px 4px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
}

.jn-card-body {
  min-width: 0;
  padding: 0 12px 12px;
}

.field-line,
.empty-line,
.habit-note {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.field-name {
  font-weight: 700;
}

.todo-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.todo {
  display: flex;
  align-items: baseline;
  gap: 8px;
  max-width: 100%;
  margin: 0 0 6px;
  line-height: 1.4;
}

.todo-mark {
  flex: 0 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 2px solid var(--jn-line);
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  transform: translateY(2px);
}

.todo.done .todo-mark {
  border-color: var(--jn-ok);
  color: var(--jn-ok);
}

.todo-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.todo-status {
  flex: 0 0 auto;
  color: var(--jn-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.jn-mark {
  padding: 0 0.28em;
  border-radius: 0.35em;
  background: var(--jn-mark-bg, #fef3c7);
  box-shadow: inset 0 0 0 1px var(--jn-mark-line, #d97706);
  color: inherit;
  font-weight: 600;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.info-wrap {
  position: relative;
  display: block;
  max-width: 100%;
  margin: 0 0 8px;
}

.info-tip {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  border: 2px solid var(--jn-line);
  border-radius: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.info-by {
  display: block;
  margin-top: 4px;
  color: var(--jn-muted);
}

html.dark .dx-card,
html.dark .info-tip,
html.dark .dx-btn--ghost,
html.dark .info-btn,
html.dark #prev,
html.dark #next,
html.dark #today {
  background-color: #1f1f1f;
  color: #efeeec;
}

html.dark .dx-btn {
  background-color: #60a5fa;
  color: #0d0d0d;
}

html.dark .dx-btn--ghost {
  background-color: #1f1f1f;
  color: #efeeec;
  border-color: #d4d4d4;
}

.jn-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: 28px;
  max-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--jn-line);
  border-radius: 999px;
  background: var(--dx-card-solid);
  color: var(--dx-text);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.jn-chip-emoji {
  flex: 0 0 auto;
  font-size: 0.95rem;
  line-height: 1;
}

.jn-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}

.jn-dot {
  box-sizing: border-box;
  width: 8px;
  height: 8px;
  border: 1.5px solid var(--jn-dot-off);
  border-radius: 50%;
  background: transparent;
}

.jn-dot.on {
  border-color: var(--jn-dot-on);
  background: var(--jn-dot-on);
}

.is-error {
  color: var(--jn-error);
}

.is-done {
  color: var(--jn-ok);
  border-color: var(--jn-ok);
}

.is-miss {
  color: var(--jn-miss);
  background: transparent;
  border: 2px solid var(--jn-miss);
}

.is-unknown {
  color: var(--jn-unknown);
  background: transparent;
  border: 2px dashed var(--jn-unknown);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
