/*
 * Copyright (c) 2017 XMLmind Software. All rights reserved.
 *
 * This file is part of the XMLmind XML Editor project.
 * For conditions of distribution and use, see the accompanying legal.txt file.
 */

@import "xhtml-config:css/xhtml5.css";

/* Do not report an error if the "Easy Profiling" add-on 
   has not been installed. */
@import url(---profiling:common/profiling.imp);

@namespace "http://www.xmlmind.com/schema/ebook";
@namespace ebk "http://www.xmlmind.com/schema/ebook";
@namespace html "http://www.w3.org/1999/xhtml";

/*
 * EbookStyleSheetExtension is the implementation of methods 
 * sectionHeader(), idIcon(), pageIcons().
 *
 * Constructor arguments:
 * 
 * showPageTitles true|false 
 *     Specifies whether page titles are displayed by the stylesheet
 *     when head/title missing.
 *     Value "true" implies that many referenced HTML files may be loaded 
 *     (and cached) in order to obtain the titles of these pages.
 *     Value "false" is therefore adapted to large ebooks and/or 
 *     slow computers/slow network connections.
 *
 * Methods:
 *
 * sectionHeader([ title_property_name ','  title_property_value ]*)
 *     Generates: collapser(), element-name(), a compact representation 
 *     of most other attributes, a representation of attribute "keys", 
 *     a navigation title along with a representation of attribute "locktitle", 
 *     a representation of attribute "type", a representation of 
 *     attribute "keyref", a representation of attribute "href", chunkIcon().
 *
 * idIcon()
 *     Generates an icon followed by the value of attribute "xml:id".
 *
 * pageIcons()
 *     Generates an icon representing samepage="true" and 
 *     an icon having a tooltip representing the value of attribute "pagename".
 */
@extension "com.xmlmind.xmleditext.ebook.EbookStyleSheetExtension true";

book,
frontmatter,
backmatter,
part,
appendices,
chapter,
appendix,
section {
    display: block;
    collapsible: yes;
    not-collapsible-head: 1; /*header*/
}

frontmatter,
backmatter,
part,
appendices {
    margin-left: 2em;
    margin-top: 1em;
    margin-bottom: 1em;
}

frontmatter,
backmatter {
    border: 1px dotted black;
    padding: 0.25em;
}

chapter,
appendix {
    margin-left: 2em;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

section {
    margin-left: 2em;
    margin-top: 0.125em;
    margin-bottom: 0.125em;
}

frontmatter > section,
backmatter > section {
    margin-left: 1em;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

book:before,
frontmatter:before,
backmatter:before,
part:before,
appendices:before,
chapter:before,
appendix:before,
section:before {
    display: inline;
    content: invoke("sectionHeader", color, #206080);
}

toc,
lot,
lof,
lox,
loe,
index {
    display: block;
    font-weight: bold;
    color: #206080;
    margin-left: 1em;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

@property-value booklist-content(title)
    title invoke("idIcon") invoke("pageIcons");

toc {
    content: booklist-content("Table of Contents");
}

lot {
    content: booklist-content("List of Tables");
}

lof {
    content: booklist-content("List of Figures");
}

lox {
    content: booklist-content("List of Examples");
}

loe {
    content: booklist-content("List of Equations");
}

index {
    content: booklist-content("Index");
}

headcommon,
head,
body {
    display: block;
    padding: 0.25em;
    margin-left: 1em;
    margin-top: 0.125em;
    margin-bottom: 0.125em;
}

headcommon {
    border: 1px solid #E0D0C0;
    border-radius: 3px;
    background-color: #FFEEDD;
}

head {
    border: 1px solid #E0E0D0;
    border-radius: 3px;
    background-color: #FFFFEE;
}

body {
    border: 1px dotted black;
}

title {
    display: block;
    font-weight: bold;
    color: #206080;
    margin-top: 0.25em;
    margin-bottom: 0.25em;
}

content {
    display: block;
    content: element-label() invoke("idIcon")
             " " icon(right-link, navy) decode-uri(attr(href));
    margin-top: 0.125em;
    margin-bottom: 0.125em;
}

@property-value related-content(title)
    text(title, font-weight, bold, color, #206080)  invoke("idIcon")
    " " icon(right-link, navy) attr(ids);

related {
    display: block;
    content: related-content("Related information");
    margin-left: 1em;
    margin-top: 0.125em;
    margin-bottom: 0.125em;
}

related[relation] {
    content: related-content(attr(relation));
}
