/**
 * HANSTORPSBLADET — Modern Newspaper Design
 * Compatible with Edge 15+ (2017+)
 */

/* ===== CSS Variables ===== */
:root {
  --bg:           #f5f0e8;
  --card-bg:      #ffffff;
  --text:         #2d2416;
  --text-muted:   #6b5e4e;
  --masthead:     #1c1410;
  --accent:       #8b1a1a;
  --accent-hover: #6e1414;
  --border:       #d4c4a8;
  --shadow-sm:    0 1px 4px rgba(0, 0, 0, 0.08);
  --shadow-md:    0 4px 16px rgba(0, 0, 0, 0.13);
  --radius:       4px;
}

/* ===== Reset ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== Masthead ===== */
.masthead {
  background: var(--masthead);
  color: white;
  text-align: center;
  padding: 28px 20px 22px;
  border-bottom: 4px solid var(--accent);
}

.mastheadRule {
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
  max-width: 560px;
  margin: 10px auto;
}

.masthead h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 52px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffffff;
  line-height: 1.1;
}

.masthead p {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 4px;
}

/* ===== Login screen ===== */
#loginScreen {
  display: none;
}

#loginScreen.visible {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px 80px;
}

.loginCard {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 42px 46px;
  width: 100%;
  max-width: 420px;
  border-top: 4px solid var(--accent);
}

.loginCard h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  margin-bottom: 5px;
  color: var(--text);
}

.loginSubtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.loginCard label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.loginCard input[type="password"],
.loginCard input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 17px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-family: monospace;
  transition: border-color 0.15s;
  background: var(--bg);
  color: var(--text);
}

.passwordField {
  position: relative;
  margin-bottom: 20px;
}

.passwordField input[type="password"],
.passwordField input[type="text"] {
  margin-bottom: 0;
  padding-right: 48px;
}

.togglePasswordBtn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
}

.togglePasswordBtn:hover {
  background: transparent;
  color: var(--accent);
}

.eyeIcon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.loginCard input[type="password"]:focus,
.loginCard input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.loginCard button[type="submit"] {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: background 0.15s;
  font-family: inherit;
}

.loginCard button[type="submit"]:hover {
  background: var(--accent-hover);
}

.loginNote {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.errorMessage {
  display: none;
  padding: 11px 14px;
  background: #fef2f2;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: #7f1d1d;
  font-size: 14px;
  margin-bottom: 18px;
}

.errorMessage.visible {
  display: block;
}

/* ===== Main screen ===== */
#mainScreen {
  display: none;
}

#mainScreen.visible {
  display: block;
}

/* ===== Page content wrapper ===== */
.pageContent {
  max-width: 1140px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ===== Controls bar ===== */
.controls {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-box-align: end;
  -ms-flex-align: end;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 32px;
}

.controlsLeft {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 14px;
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
}

.filterGroup {
  min-width: 178px;
}

.filterGroup label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.filterGroup select,
.filterGroup input[type="text"] {
  width: 100%;
  padding: 9px 12px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  font-family: inherit;
}

.filterGroup select:focus,
.filterGroup input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.btnLogout {
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-transition: border-color 0.15s, color 0.15s;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: inherit;
  -ms-flex-item-align: end;
  align-self: flex-end;
}

.btnLogout:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Year section ===== */
.yearSection {
  margin-bottom: 48px;
}

.yearSectionHead {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.yearSectionHead h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  color: var(--text);
  white-space: nowrap;
}

.yearRule {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== Cards grid (flexbox for Edge 15 compat) ===== */
.cardsGrid {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 22px;
}

/* ===== Newsletter card ===== */
.newsletterCard {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  width: calc(33.333% - 15px);
  min-width: 200px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  border-top: 3px solid var(--accent);
  -webkit-transition: -webkit-transform 0.15s, box-shadow 0.15s;
  transition: transform 0.15s, box-shadow 0.15s;
}

.newsletterCard:hover {
  -webkit-transform: translateY(-3px);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

/* ===== Thumbnail ===== */
.thumbnailWrap {
  width: 100%;
  padding-top: 141%;    /* A4 portrait aspect ratio */
  position: relative;
  background: #ede8de;
  overflow: hidden;
}

.thumbnailWrap img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -o-object-fit: contain;
  object-fit: contain;
  display: block;
}

.thumbnailPlaceholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  gap: 10px;
}

.thumbIcon {
  width: 48px;
  height: 60px;
  fill: var(--border);
}

.thumbnailPlaceholder span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ===== Card body ===== */
.cardBody {
  padding: 16px 18px 18px;
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
}

.cardLabel {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--accent);
  margin-bottom: 3px;
}

.cardIssue {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.cardMeta {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.cardMetaItem {
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 5px;
}

.metaIcon {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.cardSpacer {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
}

.cardActions {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.btnOpen {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  padding: 11px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  cursor: pointer;
  -webkit-transition: background 0.15s;
  transition: background 0.15s;
  font-family: inherit;
}

.btnOpen:hover {
  background: var(--accent-hover);
}

.btnDownload {
  padding: 11px 13px;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-transition: border-color 0.15s, color 0.15s;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.dlIcon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.btnDownload:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Empty state ===== */
.emptyState {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 18px;
  font-style: italic;
}

.searchSummary {
  display: none;
  margin-top: -12px;
  margin-bottom: 18px;
  font-size: 13px;
  color: var(--text-muted);
}

.cardSnippet {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  min-height: 38px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== PDF Viewer modal ===== */
#pdfViewer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.87);
  z-index: 1000;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
}

#pdfViewer.visible {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
}

.viewerHeader {
  background: var(--masthead);
  color: white;
  padding: 13px 20px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 14px;
  border-bottom: 3px solid var(--accent);
  -ms-flex-negative: 0;
  flex-shrink: 0;
  -ms-flex-wrap: wrap;
  flex-wrap: wrap;
}

.viewerTitle {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  min-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viewerBtns {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 8px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.btnViewer {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.btnViewerPrimary {
  background: var(--accent);
  color: white;
}

.btnViewerPrimary:hover {
  background: var(--accent-hover);
}

.btnViewerSecondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.btnViewerSecondary:hover {
  background: rgba(255, 255, 255, 0.22);
}

.btnViewerArrow {
  width: 40px;
  padding: 8px 0;
  text-align: center;
  font-size: 20px;
  line-height: 1;
}

.viewerBody {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  overflow: hidden;
  background: #444;
}

.viewerBody iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .masthead h1 {
    font-size: 36px;
  }

  .newsletterCard {
    width: calc(50% - 11px);
  }
}

@media (max-width: 580px) {
  .masthead h1 {
    font-size: 26px;
    letter-spacing: 0.05em;
  }

  .masthead p {
    display: none;
  }

  .pageContent {
    padding: 20px 14px 60px;
  }

  .newsletterCard {
    width: 100%;
  }

  .controls {
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: stretch;
    -ms-flex-align: stretch;
    align-items: stretch;
  }

  .controlsLeft {
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
  }

  .btnLogout {
    width: 100%;
    text-align: center;
  }

  .loginCard {
    padding: 28px 22px;
  }

  .viewerHeader {
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: start;
    -ms-flex-align: start;
    align-items: flex-start;
    gap: 10px;
  }

  .viewerBtns {
    width: 100%;
  }

  .btnViewer {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    text-align: center;
  }
}

/* ===== Accessibility ===== */
a:focus,
button:focus,
input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
