/* Base, shared controls, page frame and sidebar. Colours and type come from tokens.css. */

:root {
  --sb-w: var(--sidebar-w);
  --rail-w: 68px;
  --gutter: clamp(20px, 5vw, 64px);
  --hairline: rgba(200, 163, 90, .42);
  --hairline-soft: rgba(200, 163, 90, .2);
  --wood: #4a3222;
  --wood-light: #6b4a30;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-gutter: stable;
  background: var(--kon-deep);
}

html.is-locked {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--kon-deep);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, p, figure, ul, ol, blockquote, pre {
  margin: 0;
}

ul, ol {
  padding: 0;
}

img, video, iframe {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
}

input, textarea {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--kin);
  outline-offset: 3px;
  border-radius: 2px;
}

.main :focus-visible,
.modal :focus-visible {
  outline-color: var(--kin-deep);
}

.main:focus,
.main:focus-visible {
  outline: none;
}

::selection {
  background: rgba(200, 163, 90, .38);
  color: var(--sumi);
}

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

.icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  line-height: 0;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: calc(var(--z-overlay) + 12);
  padding: 8px 16px;
  background: var(--kon);
  color: var(--kin-light);
  border: 1px solid var(--kin);
  font-family: var(--font-latin);
  letter-spacing: .08em;
  text-decoration: none;
  transition: top var(--dur-fast) ease;
}

.skip-link:focus {
  top: 12px;
}

.noscript {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 200;
  padding: 14px 20px;
  background: var(--kon);
  color: var(--on-dark);
  text-align: center;
}

/* ---------- buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 20px;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  background: var(--kinari);
  color: var(--ink);
  font-family: var(--font-latin);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .1em;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.btn:hover {
  border-color: var(--kin-deep);
  background: #fffaf0;
}

.btn:disabled {
  opacity: .55;
}

.btn--primary {
  background: var(--kon);
  border-color: var(--kin-deep);
  color: var(--kin-light);
  box-shadow: inset 0 0 0 1px rgba(233, 213, 163, .14);
}

.btn--primary:hover {
  background: var(--ai);
  border-color: var(--kin);
}

.btn--danger {
  background: var(--shu);
  border-color: var(--beni);
  color: var(--kinari);
}

.btn--danger:hover {
  background: var(--shu-bright);
  border-color: var(--beni);
}

.btn--small {
  min-height: 34px;
  padding: 5px 13px;
  font-size: .9rem;
}

.btn--onDark {
  background: transparent;
  border-color: var(--hairline);
  color: var(--kin-light);
}

.btn--onDark:hover {
  background: rgba(200, 163, 90, .14);
  border-color: var(--kin);
}

.text-btn {
  position: relative;
  padding: 4px 2px;
  font-family: var(--font-latin);
  font-size: .95rem;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--hairline);
  transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}

.text-btn:hover {
  color: var(--ink);
  border-color: var(--kin-deep);
}

.text-btn--danger {
  color: var(--beni);
}

.text-btn--danger:hover {
  color: var(--shu);
  border-color: var(--shu);
}

/* ---------- form fields ---------- */

.field {
  display: grid;
  gap: 6px;
  margin-top: 18px;
}

.field__label {
  font-family: var(--font-latin);
  font-size: .86rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field__input {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  background: #fffdf6;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  box-shadow: inset 0 1px 3px rgba(42, 38, 34, .07);
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

textarea.field__input {
  resize: vertical;
  min-height: 96px;
}

.field__input::placeholder {
  color: var(--ink-faint);
  opacity: .85;
}

.field__input:focus,
.field__input:focus-visible {
  outline: none;
  border-color: var(--kin-deep);
  box-shadow: 0 0 0 3px rgba(200, 163, 90, .32), inset 0 1px 3px rgba(42, 38, 34, .05);
}

.field__hint {
  font-size: .86rem;
  color: var(--ink-faint);
  line-height: 1.5;
}

.form-error {
  min-height: 1.5em;
  margin-top: 14px;
  color: var(--beni);
  font-size: .94rem;
  line-height: 1.5;
}

.form-error:empty {
  min-height: 0;
  margin-top: 0;
}

/* ---------- page frame ---------- */

.main {
  position: relative;
  z-index: var(--z-content);
  min-height: 100vh;
  margin-left: var(--sb-w);
  background-color: var(--washi);
  overflow-x: clip;
  transition: margin-left var(--dur-mid) var(--ease-fold);
}

.view {
  min-height: 100vh;
  padding-bottom: clamp(72px, 12vh, 140px);
}

.wrap {
  width: 100%;
  max-width: 1160px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.rule {
  height: 1px;
  margin: clamp(26px, 4vw, 44px) 0;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--kin-deep) 18%, var(--kin) 50%, var(--kin-deep) 82%, transparent);
  opacity: .7;
}

.hint-line {
  padding: 14px 18px;
  border: 1px dashed var(--paper-edge);
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: .96rem;
}

/* ---------- sidebar ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: var(--z-sidebar);
  width: var(--sb-w);
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(35, 50, 83, .5) 0%, rgba(13, 18, 32, 0) 34%),
    linear-gradient(180deg, var(--kon) 0%, var(--kon-deep) 100%);
  color: var(--on-dark);
  border-right: 1px solid var(--kin-deep);
  box-shadow: 1px 0 0 rgba(233, 213, 163, .12), 12px 0 36px -18px rgba(0, 0, 0, .7);
  transition: width var(--dur-mid) var(--ease-fold), transform var(--dur-mid) var(--ease-fold), visibility 0s;
}

.sidebar .sidebar__pat {
  position: absolute;
  inset: 0;
  --pat-color: var(--kin);
  opacity: .07;
  pointer-events: none;
}

.sidebar__head,
.sidebar__nav,
.sidebar__foot {
  position: relative;
}

.sidebar__head {
  padding: 30px 22px 22px;
  border-bottom: 1px solid var(--hairline-soft);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  text-decoration: none;
  color: var(--kin-light);
}

.brand__crest {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: var(--kin);
}

.brand__crest svg {
  width: 100%;
  height: 100%;
}

.brand__text {
  display: grid;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.brand .brand__title {
  font-family: var(--font-latin);
  font-size: 1.32rem;
  font-weight: 600;
  letter-spacing: .26em;
  margin-right: -.26em;
  line-height: 1.35;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.brand__title {
  color: var(--kin-light);
}

.brand__tagline {
  font-family: var(--font-latin);
  font-style: italic;
  font-size: .98rem;
  line-height: 1.45;
  color: var(--on-dark-soft);
  overflow-wrap: anywhere;
}

.sidebar__toggle {
  position: absolute;
  top: 12px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--on-dark-soft);
  transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease, transform var(--dur-mid) var(--ease-fold);
}

.sidebar__toggle:hover {
  color: var(--kin-light);
  background: rgba(200, 163, 90, .12);
}

.sidebar__nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 12px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 163, 90, .45) transparent;
}

.sidebar__nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(200, 163, 90, .4);
  border-radius: 3px;
}

.sidebar__nav::-webkit-scrollbar-track {
  background: transparent;
}

.nav-list {
  position: relative;
  display: grid;
  gap: 3px;
  list-style: none;
}

.nav-list.is-sorting {
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

/* the thin gold marker beside the active entry */
.nav-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 2px;
  background: var(--kin-foil);
  transform: scaleY(0);
  transform-origin: 50% 50%;
  transition: transform var(--dur-mid) var(--ease-brush);
  pointer-events: none;
}

.nav-item.is-active::before {
  transform: scaleY(1);
}

.nav-link {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px 8px 14px;
  border-radius: var(--radius);
  color: var(--on-dark-soft);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: .08em;
  line-height: 1.4;
  text-decoration: none;
  transition: color var(--dur-fast) ease;
}

.nav-link:hover {
  color: var(--on-dark);
}

.nav-item.is-active .nav-link {
  color: var(--kin-light);
}

.nav-link__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seal {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(200, 163, 90, .5);
  border-radius: 4px;
  background: rgba(200, 163, 90, .06);
  color: var(--kin-light);
  font-family: var(--font-brush);
  font-size: 1.1rem;
  line-height: 1;
  transition: background-color var(--dur-mid) var(--ease-brush), border-color var(--dur-mid) ease, color var(--dur-mid) ease, box-shadow var(--dur-mid) ease;
}

.nav-link:hover .seal {
  border-color: var(--kin);
}

.nav-item.is-active .seal {
  background: var(--shu);
  border-color: var(--shu-bright);
  color: var(--kinari);
  box-shadow: inset 0 0 0 2px rgba(251, 246, 234, .16), 0 0 20px -6px rgba(220, 74, 54, .8);
}

.nav-item.is-pending {
  opacity: .55;
  pointer-events: none;
}

.nav-item.is-pending .seal {
  border-style: dashed;
}

.nav-item.is-sortable .nav-link {
  padding-right: 34px;
}

.nav-item.is-dragging {
  opacity: .45;
}

.nav-more {
  position: absolute;
  right: 4px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: -14px;
  border-radius: 50%;
  color: var(--on-dark-soft);
  opacity: 0;
  transition: opacity var(--dur-fast) ease, color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}

.nav-item:hover .nav-more,
.nav-item:focus-within .nav-more,
.nav-more[aria-expanded="true"] {
  opacity: 1;
}

.nav-more:hover,
.nav-more[aria-expanded="true"] {
  color: var(--kin-light);
  background: rgba(200, 163, 90, .16);
}

@media (hover: none) {
  .nav-more {
    opacity: .8;
  }
}

.nav-drop {
  position: absolute;
  left: 6px;
  right: 6px;
  top: -1px;
  height: 2px;
  background: var(--kin-light);
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(233, 213, 163, .8);
  pointer-events: none;
}

/* the "+" strip, a hanging paper slip */
.nav-new {
  margin-top: 14px;
  padding: 0 2px;
  list-style: none;
}

.tanzaku {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 7px 14px 7px 12px;
  border: 1px solid var(--paper-edge);
  border-radius: 2px;
  background: linear-gradient(180deg, var(--kinari), var(--washi-deep));
  color: var(--ink-soft);
  font-family: var(--font-latin);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-align: left;
  box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .7), inset 0 0 0 3px rgba(255, 255, 255, .28);
  transition: color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.tanzaku:hover {
  color: var(--ink);
  box-shadow: 0 10px 18px -8px rgba(0, 0, 0, .75), inset 0 0 0 3px rgba(255, 255, 255, .4);
}

.tanzaku__plus {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--shu);
  color: var(--shu);
}

.tanzaku--editing {
  cursor: text;
  border-color: var(--kin);
  box-shadow: 0 0 0 3px rgba(200, 163, 90, .35), 0 6px 14px -8px rgba(0, 0, 0, .7);
}

.tanzaku__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 0;
  border: 0;
  border-bottom: 1px solid var(--paper-edge);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: 1rem;
  letter-spacing: .04em;
}

.tanzaku__input:focus,
.tanzaku__input:focus-visible {
  outline: none;
  border-bottom-color: var(--shu);
}

.nav-new__hint {
  margin-top: 8px;
  font-family: var(--font-latin);
  font-style: italic;
  font-size: .86rem;
  color: var(--on-dark-soft);
  text-align: center;
}

.sidebar__foot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 14px 14px 18px;
  border-top: 1px solid var(--hairline-soft);
}

.sidebar__foot .seal-btn {
  align-self: center;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(194, 56, 42, .65);
  border-radius: 5px;
  background: transparent;
  color: rgba(220, 74, 54, .9);
  font-family: var(--font-brush);
  font-size: 1.2rem;
  line-height: 1;
  opacity: .7;
  transition: opacity var(--dur-fast) ease, background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.sidebar__foot .seal-btn:hover,
.sidebar__foot .seal-btn:focus-visible {
  opacity: 1;
  background: var(--shu);
  color: var(--kinari);
}

.foot-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--on-dark-soft);
  font-family: var(--font-latin);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-align: left;
  transition: color var(--dur-fast) ease;
}

.foot-btn:hover {
  color: var(--kin-light);
}

/* mobile menu button + scrim */
.menu-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: calc(var(--z-sidebar) - 2);
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--kin-deep);
  border-radius: 4px;
  background: rgba(20, 27, 46, .92);
  color: var(--kin-light);
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .8);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-sidebar) - 1);
  background: rgba(13, 18, 32, .62);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* ---------- collapsed rail (desktop only) ---------- */

@media (min-width: 861px) {
  html.sb-collapsed {
    --sb-w: var(--rail-w);
  }

  .sb-collapsed .sidebar__head {
    padding: 52px 0 16px;
  }

  .sb-collapsed .brand__crest {
    width: 38px;
    height: 38px;
  }

  .sb-collapsed .brand__text,
  .sb-collapsed .nav-link__title,
  .sb-collapsed .nav-more,
  .sb-collapsed .tanzaku__label,
  .sb-collapsed .nav-new__hint,
  .sb-collapsed .foot-btn__label {
    display: none;
  }

  .sb-collapsed .sidebar__toggle {
    right: 50%;
    margin-right: -15px;
    transform: rotate(180deg);
  }

  .sb-collapsed .sidebar__nav {
    padding-inline: 0;
    scrollbar-width: none;
  }

  .sb-collapsed .sidebar__nav::-webkit-scrollbar {
    display: none;
  }

  .sb-collapsed .nav-link,
  .sb-collapsed .nav-item.is-sortable .nav-link {
    justify-content: center;
    padding: 8px 0;
  }

  .sb-collapsed .nav-new {
    padding: 0;
    display: grid;
    justify-content: center;
  }

  .sb-collapsed .tanzaku {
    width: 40px;
    min-height: 40px;
    padding: 0;
    justify-content: center;
  }

  .sb-collapsed .sidebar__foot {
    align-items: center;
    padding-inline: 0;
  }

  .sb-collapsed .foot-btn {
    padding: 9px;
  }
}

/* ---------- drawer (narrow screens) ---------- */

@media (max-width: 860px) {
  :root {
    --sb-w: 0px;
  }

  .main {
    margin-left: 0;
  }

  .menu-btn {
    display: grid;
  }

  .sidebar {
    width: min(86vw, 320px);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform var(--dur-mid) var(--ease-fold), visibility 0s linear var(--dur-mid);
  }

  .nav-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform var(--dur-mid) var(--ease-fold), visibility 0s;
  }

  .sidebar__toggle {
    display: none;
  }

  .nav-more {
    opacity: .8;
  }
}

@media (min-width: 861px) {
  .scrim {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .main,
  .sidebar,
  .sidebar__toggle,
  .nav-item::before,
  .seal,
  .btn,
  .skip-link {
    transition: none !important;
  }
}
