/* ============================================================
   style.css — Macintosh System 1 (1984)
   1-bit svartvitt. Allt ritas i Chicago. Grått = dither-mönster.
   ============================================================ */

@font-face {
  font-family: "ChicagoFLF";
  src: url("fonts/ChicagoFLF.woff2") format("woff2"),
       url("fonts/ChicagoFLF.woff") format("woff");
  font-display: swap;
}

:root {
  --chicago: "ChicagoFLF", "Geneva", "Tahoma", sans-serif;
  --black: #000;
  --white: #fff;
  --menubar-h: 22px;
  --title-h: 19px;
  --sb: 16px;          /* scrollbar-tjocklek */
}

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

html, body { height: 100%; }

body {
  font-family: var(--chicago);
  font-size: 15px;
  line-height: 1.35;
  color: var(--black);
  background: var(--white);
  overflow: hidden;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  cursor: default;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

img { image-rendering: pixelated; image-rendering: crisp-edges; }
svg { shape-rendering: crispEdges; display: block; }

/* ----------------------------------------------------------------
   Skrivbordet (dithrad grå yta)
   ---------------------------------------------------------------- */

.desktop {
  position: fixed;
  inset: var(--menubar-h) 0 0 0;
  background-color: var(--white);
  background-image: url("pat-gray.png");
  background-size: 2px 2px;
  image-rendering: pixelated;
  overflow: hidden;
}

/* ----------------------------------------------------------------
   Menyrad
   ---------------------------------------------------------------- */

.menubar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--menubar-h);
  background: var(--white);
  border-bottom: 1px solid var(--black);
  display: flex;
  align-items: stretch;
  z-index: 10000;
  padding: 0 6px;
}

.menu-title {
  display: flex;
  align-items: center;
  padding: 0 9px;
  font-size: 15px;
  white-space: nowrap;
}
.menu-title.apple { padding: 0 11px; }
.menu-title.apple svg { width: 14px; height: 16px; }
.menu-title.open { background: var(--black); color: var(--white); }
.menu-title.open svg path { fill: var(--white); }

/* Dropdown */
.menu {
  position: fixed;
  top: var(--menubar-h);
  background: var(--white);
  border: 1px solid var(--black);
  box-shadow: 2px 2px 0 var(--black);
  z-index: 10001;
  padding: 2px 0;
  min-width: 160px;
}
.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 1px 16px 2px 22px;
  font-size: 15px;
  white-space: nowrap;
  position: relative;
}
.menu-item:not(.disabled):not(.sep):hover {
  background: var(--black);
  color: var(--white);
}
.menu-item .sc { font-size: 13px; opacity: .85; }
.menu-item .chk { position: absolute; left: 7px; }
.menu-item.disabled { opacity: .32; }
.menu-item.sep {
  padding: 0; margin: 3px 0;
  height: 1px; min-height: 1px;
  background-image: url("pat-gray.png");
  background-size: 2px 2px;
  pointer-events: none;
}

/* ----------------------------------------------------------------
   Ikoner (skrivbord + i fönster)
   ---------------------------------------------------------------- */

.icon {
  position: absolute;
  width: 72px;
  text-align: center;
  cursor: default;
}
.icon .glyph {
  width: 38px; height: 34px;
  margin: 0 auto 2px;
  display: flex; align-items: flex-end; justify-content: center;
}
.icon .glyph svg { width: 100%; height: 100%; }
.icon .label {
  display: inline;
  font-size: 13px;
  line-height: 1.3;
  padding: 1px 3px;
  background: var(--white);
  color: var(--black);
  overflow-wrap: break-word;
  word-break: break-word;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.icon.sel .glyph { opacity: .5; }
.icon.sel .label { background: var(--black); color: var(--white); }

/* desktop-ikoner ligger statiskt placerade via JS */

/* ----------------------------------------------------------------
   Fönster
   ---------------------------------------------------------------- */

.win {
  position: absolute;
  background: var(--white);
  border: 1px solid var(--black);
  box-shadow: 1px 1px 0 var(--black);
  display: flex;
  flex-direction: column;
  min-width: 180px;
  min-height: 120px;
}

.title-bar {
  position: relative;
  height: var(--title-h);
  flex: 0 0 var(--title-h);
  border-bottom: 1px solid var(--black);
  overflow: hidden;
}
.win.active .title-bar {
  background: repeating-linear-gradient(
    to bottom, var(--black) 0 1px, var(--white) 1px 2px);
}
.title-bar .title {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: var(--white);
  padding: 0 9px;
  font-size: 15px;
  white-space: nowrap;
  max-width: calc(100% - 56px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.win:not(.active) .title-bar .title { background: transparent; }

.close-box {
  position: absolute;
  left: 9px; top: 50%;
  transform: translateY(-50%);
  width: 11px; height: 11px;
  border: 1px solid var(--black);
  background: var(--white);
  box-shadow: 0 0 0 3px var(--white);
}
.close-box:active { background: var(--black); }
.win:not(.active) .close-box { display: none; }

/* info-rad (mappar/diskar) */
.info-line {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  padding: 1px 10px 2px;
  font-size: 13px;
  border-bottom: 1px solid var(--black);
}

/* kropp + scrollbars */
.win-body { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; }

.content-clip {
  position: absolute;
  inset: 0 var(--sb) var(--sb) 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.content-clip::-webkit-scrollbar { display: none; }

.content { padding: 0; }
.win[data-kind="document"] .content,
.win[data-kind="app"] .content { padding: 14px 16px 18px; }

/* Mac-scrollbars */
.sb {
  position: absolute;
  background-image: url("pat-gray.png");
  background-size: 2px 2px;
  image-rendering: pixelated;
}
.sb-v { top: 0; right: 0; bottom: var(--sb); width: var(--sb);
        border-left: 1px solid var(--black); }
.sb-h { left: 0; right: var(--sb); bottom: 0; height: var(--sb);
        border-top: 1px solid var(--black); }

.sb-arrow {
  position: absolute;
  width: var(--sb); height: var(--sb);
  background: var(--white);
}
.sb-v .sb-arrow.up    { top: 0;    left: 0; border-bottom: 1px solid var(--black); }
.sb-v .sb-arrow.down  { bottom: 0; left: 0; border-top: 1px solid var(--black); }
.sb-h .sb-arrow.left  { left: 0;  top: 0; border-right: 1px solid var(--black); }
.sb-h .sb-arrow.right { right: 0; top: 0; border-left: 1px solid var(--black); }
.sb-arrow::after {
  content: ""; position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 0; height: 0;
}
.sb-v .sb-arrow.up::after    { border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 5px solid var(--black); }
.sb-v .sb-arrow.down::after  { border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--black); }
.sb-h .sb-arrow.left::after  { border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-right: 5px solid var(--black); }
.sb-h .sb-arrow.right::after { border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 5px solid var(--black); }
.sb-arrow:active { background: var(--black); }
.sb-arrow:active::after { filter: invert(1); }

.sb-track { position: absolute; }
.sb-v .sb-track { top: var(--sb); bottom: var(--sb); left: 0; right: 0; }
.sb-h .sb-track { left: var(--sb); right: var(--sb); top: 0; bottom: 0; }

.sb-thumb {
  position: absolute;
  background: var(--white);
  border: 1px solid var(--black);
}
.sb-v .sb-thumb { left: 1px; right: 1px; }
.sb-h .sb-thumb { top: 1px; bottom: 1px; }
.win:not(.active) .sb-thumb { display: none; }
.win:not(.active) .sb { opacity: .55; }

.grow {
  position: absolute;
  right: 0; bottom: 0;
  width: var(--sb); height: var(--sb);
  background: var(--white);
  border-left: 1px solid var(--black);
  border-top: 1px solid var(--black);
  cursor: nwse-resize;
}
.win:not(.active) .grow { visibility: hidden; }
.grow::before, .grow::after {
  content: ""; position: absolute; border: 1px solid var(--black); background: var(--white);
}
.grow::before { left: 2px;  top: 2px;  width: 8px; height: 8px; }
.grow::after  { left: 5px;  top: 5px;  width: 8px; height: 8px; }

/* ----------------------------------------------------------------
   Innehåll: dokument
   ---------------------------------------------------------------- */

.doc h1 { font-size: 19px; line-height: 1.15; margin: 0 0 12px; }
.doc h2 { font-size: 15px; margin: 16px 0 6px; }
.doc p  { font-size: 15px; line-height: 1.5; margin: 0 0 11px; max-width: 52ch; overflow-wrap: anywhere; }
.doc h1, .doc h2, .doc li, .doc a, .doc dd, .doc .kicker { overflow-wrap: anywhere; }
.doc strong { font-weight: normal; text-decoration: underline; text-underline-offset: 2px; }
.doc em { font-style: normal; text-decoration: underline; text-underline-offset: 2px; }

.doc .kicker { font-size: 13px; margin-bottom: 4px; }
.doc .badge {
  display: inline-block;
  border: 1px solid var(--black);
  padding: 1px 8px 2px;
  font-size: 13px;
  margin-bottom: 10px;
}
.doc .readlink { margin-top: 16px; }

.doc-portrait {
  float: right;
  width: 130px; height: 130px;
  margin: 2px 0 10px 14px;
  border: 1px solid var(--black);
}

.doc dl.facts { margin-top: 16px; border-top: 1px solid var(--black); clear: both; }
.doc dl.facts > div {
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--black);
  padding: 4px 0;
  font-size: 14px;
}
.doc dl.facts dt { flex: 0 0 44%; }
.doc dl.facts dd { flex: 1; }
.doc dl.facts .secondary { opacity: .6; }

.doc ul.bullets { list-style: none; margin: 0 0 8px; }
.doc ul.bullets li { position: relative; padding: 2px 0 2px 18px; font-size: 15px; line-height: 1.4; }
.doc ul.bullets li::before { content: "•"; position: absolute; left: 4px; }

.doc ul.outlets {
  list-style: none;
  columns: 2; column-gap: 24px;
}
.doc ul.outlets li { padding: 3px 0; border-bottom: 1px solid var(--black); font-size: 14px; break-inside: avoid; }

.doc ul.contact { list-style: none; margin-top: 8px; }
.doc ul.contact li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid var(--black); font-size: 14px;
}
.doc ul.contact .k { flex: 0 0 72px; opacity: .6; }

.doc a { color: var(--black); text-decoration: underline; text-underline-offset: 2px; }

/* ----------------------------------------------------------------
   Innehåll: program (verktyg)
   ---------------------------------------------------------------- */

.app-view { text-align: center; }
.app-view .app-icon { width: 56px; height: 50px; margin: 6px auto 12px; }
.app-view .app-icon svg { width: 100%; height: 100%; }
.app-view h1 { font-size: 18px; margin-bottom: 6px; }
.app-view .badge {
  display: inline-block; border: 1px solid var(--black);
  padding: 1px 8px 2px; font-size: 12px; margin-bottom: 14px;
}
.app-view p { font-size: 14px; line-height: 1.5; max-width: 44ch; margin: 0 auto 18px; text-align: left; }
.app-view .hint { font-size: 12px; opacity: .6; margin-top: 12px; text-align: center; }

/* ----------------------------------------------------------------
   Knappar
   ---------------------------------------------------------------- */

.sysbtn {
  font-family: var(--chicago);
  font-size: 14px;
  background: var(--white);
  color: var(--black);
  border: 1px solid var(--black);
  border-radius: 9px;
  padding: 3px 16px 4px;
  text-decoration: none;
  display: inline-block;
  cursor: default;
}
.sysbtn:active { background: var(--black); color: var(--white); }
.sysbtn.default { box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--black); }

/* ----------------------------------------------------------------
   Modal / alert
   ---------------------------------------------------------------- */

.modal-overlay {
  position: fixed; inset: 0; z-index: 11000;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 18vh;
}
.modal {
  background: var(--white);
  border: 1px solid var(--black);
  box-shadow: 0 0 0 2px var(--white), 0 0 0 3px var(--black), 3px 3px 0 4px rgba(0,0,0,.35);
  padding: 20px 22px 18px;
  max-width: 340px;
  text-align: center;
}
.modal .m-row { display: flex; gap: 16px; text-align: left; align-items: flex-start; }
.modal .m-ico { flex: 0 0 40px; }
.modal .m-ico svg { width: 40px; height: 46px; }
.modal p { font-size: 15px; line-height: 1.45; margin-bottom: 4px; }
.modal .m-btns { margin-top: 18px; display: flex; gap: 12px; justify-content: center; }

/* ----------------------------------------------------------------
   Miniräknare
   ---------------------------------------------------------------- */

.calc { padding: 8px; }
.calc .disp {
  border: 1px solid var(--black);
  background: var(--white);
  text-align: right;
  font-size: 22px;
  padding: 4px 8px;
  margin-bottom: 8px;
  overflow: hidden;
  min-height: 32px;
}
.calc .keys { display: grid; grid-template-columns: repeat(4, 40px); gap: 6px; }
.calc .key {
  border: 1px solid var(--black);
  border-radius: 6px;
  background: var(--white);
  font-family: var(--chicago);
  font-size: 17px;
  height: 34px;
  display: flex; align-items: center; justify-content: center;
}
.calc .key:active { background: var(--black); color: var(--white); }
.calc .key.wide { grid-column: span 2; width: auto; }

/* Klocka */
.clock { padding: 18px 24px; text-align: center; }
.clock .t { font-size: 30px; letter-spacing: 1px; }
.clock .d { font-size: 14px; margin-top: 6px; opacity: .7; }

/* List-vy (Visa → efter namn) */
.listview { width: 100%; }
.listrow {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 12px; font-size: 14px;
  border-bottom: 1px solid var(--black);
}
.listrow .li-ico { flex: 0 0 22px; width: 22px; height: 18px; }
.listrow .li-ico svg { width: 100%; height: 100%; }
.listrow.sel { background: var(--black); color: var(--white); }
.listrow.sel svg { filter: invert(1); }

/* Tom papperskorg */
.empty-note { padding: 26px; text-align: center; opacity: .55; font-size: 14px; }

/* Om-rutan */
.about { display: flex; gap: 16px; padding: 18px; align-items: flex-start; }
.about-ico { flex: 0 0 64px; }
.about-ico svg { width: 64px; height: 76px; }
.about-tx h1 { font-size: 19px; margin-bottom: 6px; }
.about-tx p { font-size: 14px; line-height: 1.45; margin-bottom: 8px; }
.about-tx .sm { font-size: 13px; }
.about-tx .dim { opacity: .6; }

/* ----------------------------------------------------------------
   Boot
   ---------------------------------------------------------------- */

#boot {
  position: fixed; inset: 0; z-index: 12000;
  background-color: var(--white);
  background-image: url("pat-gray.png");
  background-size: 2px 2px;
  image-rendering: pixelated;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 26px;
  transition: opacity .35s ease;
}
#boot.hide { opacity: 0; pointer-events: none; }
#boot .happymac { width: 84px; height: 100px; }
#boot .welcome {
  background: var(--white);
  border: 1px solid var(--black);
  box-shadow: 0 0 0 2px var(--white), 0 0 0 3px var(--black);
  padding: 14px 30px;
  font-size: 16px;
  opacity: 0;
  transition: opacity .3s ease .1s;
}
#boot .welcome.show { opacity: 1; }

/* ----------------------------------------------------------------
   Responsivt (touch / smala skärmar)
   ---------------------------------------------------------------- */

@media (max-width: 640px) {
  body { font-size: 15px; }
  .menu-title { padding: 0 7px; font-size: 15px; }
  .desktop { inset: var(--menubar-h) 0 0 0; }
  .doc-portrait { float: none; display: block; margin: 0 auto 12px; }
  .doc ul.outlets { columns: 1; }
  .icon { width: 64px; }
}
