/* ===========================================================
   FONTROT — design tokens
   A typewritten page that occasionally misprints. Nine faces,
   struck at random, on paper that's a little too warm to be new.
   =========================================================== */

@font-face { font-family: "rot-1"; src: url("fonts/font-1.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "rot-2"; src: url("fonts/font-2.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "rot-3"; src: url("fonts/font-3.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "rot-4"; src: url("fonts/font-4.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "rot-5"; src: url("fonts/font-5.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "rot-6"; src: url("fonts/font-6.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "rot-7"; src: url("fonts/font-7.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "rot-8"; src: url("fonts/font-8.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "rot-9"; src: url("fonts/font-9.ttf") format("truetype"); font-display: swap; }

:root{
  --paper:       #efe4cc;
  --paper-2:     #e7d9b8;
  --paper-card:  #f2e9d2;
  --paper-shadow: rgba(59, 41, 22, 0.28);
  --ink:         #2a2118;
  --ink-dim:     #6b5d47;
  --ink-faint:   #a3937a;
  --rule:        #cdbc94;
  --red:         #a8362a;
  --red-dim:     #c67b6e;
  --teal:        #2e5a5a;

  --font-type:  "Special Elite", "Courier New", monospace;
  --font-mono:  "Courier Prime", "Courier New", monospace;

  --radius: 2px;
  --header-h: 58px;
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-mono);
}

body{
  background-image:
    radial-gradient(ellipse at 12% 8%, rgba(168,54,42,0.05), transparent 45%),
    radial-gradient(ellipse at 88% 92%, rgba(46,90,90,0.05), transparent 45%),
    repeating-linear-gradient(0deg, rgba(59,41,22,0.025) 0px, rgba(59,41,22,0.025) 1px, transparent 1px, transparent 3px),
    repeating-linear-gradient(90deg, rgba(59,41,22,0.015) 0px, rgba(59,41,22,0.015) 1px, transparent 1px, transparent 3px);
}

button{
  font-family: inherit;
  cursor: pointer;
}

.app{
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Titlebar ---------- */

.titlebar{
  position: relative;
  height: var(--header-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 2px solid var(--ink);
  background: var(--paper-2);
}

.titlebar::before{
  /* typewriter ribbon strip */
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: repeating-linear-gradient(
    -45deg,
    var(--red) 0px, var(--red) 8px,
    var(--ink) 8px, var(--ink) 16px
  );
  opacity: 0.85;
}

.titlebar-left{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.menu-btn{
  display: none;
  padding: 6px 10px;
  font-size: 14px;
}

.brand{
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark{
  display: flex;
  gap: 2px;
  font-size: 16px;
  line-height: 1;
  color: var(--ink);
  user-select: none;
}
.brand-mark span{ display:inline-block; }

.brand-text{
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name{
  position: relative;
  font-family: var(--font-type);
  font-weight: 400;
  font-size: 17px;
  letter-spacing: 0.08em;
  color: var(--ink);
  width: fit-content;
}

/* misprint / misregistration ghosts, comic-halftone style */
.brand-name.glitch::before,
.brand-name.glitch::after{
  content: "FONTROT";
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  animation: misprint-fade 1100ms ease-out 1 both;
}
.brand-name.glitch::before{ color: var(--red); transform: translate(1.5px, -1px); }
.brand-name.glitch::after{ color: var(--teal); transform: translate(-1.5px, 1px); }

@keyframes misprint-fade{
  0%   { opacity: 0.9; transform: translate(3px, -2px); }
  60%  { opacity: 0.55; }
  100% { opacity: 0.22; }
}

@media (prefers-reduced-motion: reduce){
  .brand-name.glitch::before,
  .brand-name.glitch::after{ animation: none; opacity: 0.22; }
}

.brand-tag{
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-style: italic;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
}

/* ---------- Buttons: typewriter keys ---------- */

.btn{
  border: 1px solid var(--ink);
  background: var(--paper-card);
  color: var(--ink-dim);
  padding: 7px 13px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  border-radius: 999px;
  text-transform: lowercase;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform 100ms ease, box-shadow 100ms ease, color 100ms ease;
}
.btn:hover{ color: var(--ink); transform: translateY(1px); box-shadow: 0 1px 0 var(--ink); }
.btn:active{ transform: translateY(2px); box-shadow: none; }
.btn:focus-visible{ outline: 2px solid var(--teal); outline-offset: 2px; }

.btn-primary{
  color: var(--paper-card);
  background: var(--ink);
  border-color: var(--ink);
}
.btn-primary:hover{ color: var(--paper); }

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

.btn-ghost{ opacity: 0.9; }

/* ---------- Workspace ---------- */

.workspace{
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ---------- Sidebar: a corkboard of index cards ---------- */

.sidebar{
  width: 250px;
  flex: 0 0 auto;
  border-right: 2px solid var(--ink);
  background: var(--paper-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 12px;
}

.eyebrow{
  font-family: var(--font-type);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  text-transform: uppercase;
}

.note-list{
  list-style: none;
  margin: 0;
  padding: 4px 14px 16px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.note-item{
  position: relative;
  padding: 10px 12px 10px 16px;
  margin-bottom: 10px;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  box-shadow: 2px 3px 0 var(--paper-shadow);
  cursor: pointer;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.note-item:nth-child(3n){ --tilt: -1.1deg; }
.note-item:nth-child(3n+1){ --tilt: 0.7deg; }
.note-item:nth-child(3n+2){ --tilt: -0.3deg; }

.note-item::before{
  /* pushpin */
  content: "";
  position: absolute;
  left: 5px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 2px var(--paper-card);
}

.note-item:hover{
  transform: rotate(0deg) translateY(-1px);
  box-shadow: 3px 4px 0 var(--paper-shadow);
}
.note-item.active{
  transform: rotate(0deg);
  border-color: var(--ink);
  box-shadow: 3px 4px 0 var(--paper-shadow);
}
.note-item.active::before{ background: var(--teal); }

.note-item-title{
  font-family: var(--font-type);
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-item.active .note-item-title{ color: var(--red); }

.note-item-meta{
  font-size: 10px;
  color: var(--ink-faint);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.empty-state{
  padding: 20px 18px;
  color: var(--ink-dim);
  font-size: 11.5px;
  line-height: 1.7;
  font-style: italic;
}
.empty-state strong{ color: var(--ink); font-style: normal; }

/* ---------- Editor pane ---------- */

.editor-pane{
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
}

.editor-toolbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--rule);
}

.title-input{
  background: transparent;
  border: none;
  border-bottom: 1px dashed transparent;
  color: var(--ink);
  font-family: var(--font-type);
  font-size: 14px;
  letter-spacing: 0.02em;
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 0;
}
.title-input::placeholder{ color: var(--ink-faint); font-style: italic; }
.title-input:focus{ outline: none; border-bottom-color: var(--ink-faint); }
.title-input:focus-visible{ outline: none; }

.toolbar-actions{
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.status{
  font-family: var(--font-mono);
  font-size: 10px;
  font-style: italic;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  min-width: 70px;
  text-align: right;
}
.status.dirty{ color: var(--red); }
.status.saved{ color: var(--teal); }

.editor-scroll{
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  background-image: repeating-linear-gradient(
    var(--paper) 0px, var(--paper) 40px,
    var(--rule) 41px, var(--paper) 42px
  );
  background-position: 0 30px;
}

.editor{
  min-height: 100%;
  padding: 30px 36px 60px;
  font-size: 23px;
  line-height: 41px;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  caret-color: var(--red);
  color: var(--ink);
}

.editor:empty::before{
  content: attr(data-placeholder);
  color: var(--ink-faint);
  font-family: var(--font-mono);
  font-style: italic;
  font-size: 13px;
  line-height: 1.6;
}

/* the nine random hands */
.fc-1{ font-family: "rot-1", ui-serif, Georgia, serif; }
.fc-2{ font-family: "rot-2", ui-sans-serif, Arial, sans-serif; }
.fc-3{ font-family: "rot-3", ui-monospace, Consolas, monospace; }
.fc-4{ font-family: "rot-4", cursive; }
.fc-5{ font-family: "rot-5", fantasy, serif; }
.fc-6{ font-family: "rot-6", "Times New Roman", serif; }
.fc-7{ font-family: "rot-7", Verdana, sans-serif; }
.fc-8{ font-family: "rot-8", "Courier New", monospace; }
.fc-9{ font-family: "rot-9", Impact, sans-serif; }

/* ---------- Status bar ---------- */

.statusbar{
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 24px;
  border-top: 1px solid var(--rule);
  font-size: 10.5px;
  font-style: italic;
  color: var(--ink-faint);
  background: var(--paper-2);
}

.statusbar-sep{ opacity: 0.6; }

.font-legend{
  display: flex;
  gap: 7px;
  font-size: 13px;
  font-style: normal;
  color: var(--ink-dim);
}

/* ---------- Scrollbars ---------- */

.note-list::-webkit-scrollbar,
.editor-scroll::-webkit-scrollbar{ width: 9px; }
.note-list::-webkit-scrollbar-thumb,
.editor-scroll::-webkit-scrollbar-thumb{
  background: var(--rule);
  border-radius: 4px;
}
.note-list::-webkit-scrollbar-track,
.editor-scroll::-webkit-scrollbar-track{ background: transparent; }

/* ---------- Responsive ---------- */

@media (max-width: 720px){
  .sidebar{
    position: fixed;
    z-index: 20;
    top: var(--header-h);
    bottom: 0;
    left: 0;
    width: 78vw;
    max-width: 300px;
    transform: translateX(-100%);
    transition: transform 160ms ease;
    box-shadow: 3px 0 20px rgba(42,33,24,0.35);
  }
  .sidebar.open{ transform: translateX(0); }
  .editor{ padding: 22px 20px 48px; font-size: 20px; line-height: 36px; }
  .editor-scroll{
    background-image: repeating-linear-gradient(
      var(--paper) 0px, var(--paper) 35px,
      var(--rule) 36px, var(--paper) 37px
    );
  }
  .brand-tag{ display: none; }
  .menu-btn{ display: inline-block; }

  .sidebar-backdrop{
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(42,33,24,0.4);
    z-index: 15;
  }
  .sidebar-backdrop[hidden]{ display: none; }
}

.sidebar-backdrop{ display: none; }
